<< Chapter < Page | Chapter >> Page > |
Direct memory access is a system to transfer data between peripheral modules and memory without using processor instructions. While its operation does occupy the memory bus, far fewer instructions require CPU interaction. This allows the CPU to work on other tasks simultaneously, or it may be be put into a low power mode.
The DMA module allows you to automatically move data between memory locations. This will also allow us to automate much of your program's execution.
We will configure the serial port (RS232) to transmit data. Just like before create a new project and do the following: disable the watchdog timer, and initialize the master clock and i2c. This should now be standard for all new projects. To set up the UART to use RS232 we must set the following registers:
U1BR0 = 0x7c;
and
U1BR1 = 0x01;
This will set the baud rate at 19,200 bits per second.To transmit data, check if the UTXIFG1 flag is set in UTXIFG1. Once the flag is set you may write directly to TXBUF1, and that data will be transmitted. Now, come up with an array of ASCII characters in hexadecimal notation, and load each character in the TXBUF1 one at a time. Don't for get to add a new line character,
/n
, at the end of your message.
To test your project open up HyperTerminal, and set the correct baud rate (19200). All other default settings should be fine. If you correctly configured the UART then you should see your message in the terminal.
Once you have verified that you can transmit data to the serial port, load the
TXBUF1
via DMA. You may trigger the DMA any way you wish. This will eliminate most of the work that the processor has to do.
Modify the first problem so that you input something into ADC0 and DMA the samples to the serial port. Come up with some way for a computer to read those values, HyperTerminal or otherwise.
Notification Switch
Would you like to follow the 'Microcontroller and embedded systems laboratory' conversation and receive update notifications?