circuitcellar.com
Magazine Support   Digital Library   Products & Services   Suppliers Directory 
 
 





 

October 2006, Issue 195

Generate Video from Software

 


by René Geraets

Start Video Signal Anatomy Transforming Digital I/O Output Resolution Memory Restrictions Using DMA Perfect Fit Sources and PDF

USING DMA

The large amount of RAM (for this type of microcontroller) in the M16C/62P is not the only nice feature I use for video production. The M16C/62P microcontroller’s DMA controller also comes in handy. The DMA controller can be configured to repeatedly copy bytes of data from one location to the other, where either the source address pointer or destination address pointer can be automatically incremented. The trigger for each successive copy action can be chosen from a variety of interrupt sources. And because the M16C/62P uses memory-mapped I/O, any peripheral or control registers can be the source or destination of the transfer.

An obvious application for the DMA controller is to create large communication buffers (e.g., to transmit a large block of data over the UART in one go). Set the source pointer to the beginning of your buffer, set the destination pointer to the UART data register, and select the UART transmit interrupt as the trigger for the DMA actions. Now each time a byte transmits over the UART, the DMA controller will automatically feed it the next byte.

Any memory address can be chosen as the output location. So that means not only communication registers like the UART data register, but also less obvious locations like the address of an I/O port. And, instead of the UART transmit interrupt, a timer interrupt can be chosen as the trigger for the DMA copy actions. Well, that’s exactly what I need to produce the video data!

I set the source pointer to the 23-KB chunk of memory reserved to store the output pixels and have it increment after every copy action. I fix the destination pointer to the memory-mapped I/O address of the output port containing the video output pins. I then trigger the copy actions from a timer that’s set to a frequency of 3 MHz (the pixel output frequency). Instead of having to feed each individual pixel to the I/O port (one action every 8 clock cycles), the processor now has to reconfigure the DMA controller only once per video line (one action every 1536 clock cycles). As a result, the DMA controller inside the M16C/62P does the actual video output. The main processor is then free to perform the other tasks, like interfacing to the CD player, filling the frame buffer with the strings, and checking and responding to user input.