Support for DMA controller

DMA controller allows an efficient data transfer between peripheral devices, memory and microcontroller (PDC - Peripherial DMA). Blocks of data are transmitted without the participation of the core, thereby blocking the implementation of the program at the time of transfer. To program the channel of DNA must be given the amount of data to be uploaded, and the address at which they are located. The register which contains the amount of data to transfer after sending each byte is decremented, and the transmission is completed when it reaches a record value of 0 (doubles as a set appropriate flag indicating the completion of the operation).

The following program is designed how to send a string of characters via the port DBGU . These characters can be read on a computer using HyperTerminal.


#include "library.h"
void main(void)
{
	char tekst[]=Test DMA in uC SAM7S \n\r;
	int i,j;

	DBGU->BAUD_RATE_GEN_R = 156;			//1
	DBGU->MODE_R = DBGU_MODE_NORMAL | DBGU_PARITY_NONE;
	DBGU->CONTROL_R = DBGU_TX_ENABLE | DBGU_RX_ENABLE ;

	PIO->PERIPH_A_SELECT_R=PIO_PA9 | PIO_PA10;	//2
	PIO->PIO_DISABLE_R=PIO_PA9 | PIO_PA10;

	while(1)
	{
		PDC_DBGU->CONTROL_R=PDC_TX_DISABLE;	//3
		PDC_DBGU->TX_PTR_R=(void*)tekst;	//4
		PDC_DBGU->TX_CNT_R=strlen(tekst);	//5
		PDC_DBGU->CONTROL_R=PDC_TX_ENABLE;	//6
		for(i=0; i<4000; i++)			//7
			for(j=0; j<500; j++) {};
                      					//8
		while(!DBGU->INT_STATUS_R & DBGU_TX_BUFS_EMPTY);
	}
}


1. Determining the performance of the port asynchronous serial transmission of DBGU to work with a frequency of 19,200 baud and bit without parity.
2. The pins of A9 and A10 set to work with peripheral device A, and disconnect them from the port PIO.
3. Disabling DMA channel for the port DBGU.
4. Address the first item Buffer.
5. To indicate the quantity of items to be sent.
6. Enabling DMA.
7. Wait a secound
8. Optional loop performed until the completion of signal to send data (that was essential if there was no loop late).

The second program allows you to receive data from HyperTerminal (6 characters), and then these characters are sent by SAM7S via DBGU and displayed on the computer.


#include "library.h"
void main(void)
{
	char text[6];
	int i,j;

	DBGU->BAUD_RATE_GEN_R = 156;			//1
	DBGU->MODE_R = DBGU_MODE_NORMAL | DBGU_PARITY_NONE;
	DBGU->CONTROL_R = DBGU_TX_ENABLE | DBGU_RX_ENABLE ;

	PIO->PERIPH_A_SELECT_R = PIO_PA9 | PIO_PA10;	//2
	PIO->PIO_DISABLE_R = PIO_PA9 | PIO_PA10;

	while(1)
	{

		PDC_DBGU->CONTROL_R = PDC_RX_DISABLE;	//3
		PDC_DBGU->RX_PTR_R = (void*)text;	//4
		PDC_DBGU->RX_CNT_R = 6;			//5
		PDC_DBGU->CONTROL_R = PDC_RX_ENABLE;	//6
							//7
		while(DBGU->INT_STATUS_R & DBGU_RX_BUFS_FULL);

		PDC_DBGU->CONTROL_R = PDC_TX_DISABLE;	//8
		PDC_DBGU->TX_PTR_R = (void*)text;	//9
		PDC_DBGU->TX_CNT_R = 6;			//10
		PDC_DBGU->CONTROL_R = PDC_TX_ENABLE;	//11
							//12
		while(!DBGU->INT_STATUS_R & DBGU_TX_BUFS_EMPTY);
	}
}

Try my Android Apps. It is cool Flashlight Galaxy for Samsung Galaxy devices.

1. Determining the performance of the port DBGU.
2. A the tip of A9 and A10 peripheral devices connected to A.
3. PDC halting channel receiver PDC.
4. Address the first item Buffer.
5. To indicate the quantity of items to be sent by the PDC
6. Enabling channel receiver
7. Loop stops exercise program until you have received 6 characters by the port DBGU.
8. Halting channel broadcasting PDC
9. Address the first item Buffer
10. To indicate the quantity of items to be sent to the printer to the computer DBGU
11. Enabling channel broadcasting
12. Stop the exercise of the loop until the dispatch of 6 characters.

Source code written in the software company uVision3 Keil on the basis of the book, Dr Eng. J. Augustyn Projektowanie systemow wbudowanych na przykladzie rodziny SAM7S z rdzeniem ARM7TDMI. Necessary library can be downloaded from www.sparrow-rt.com

 
>