FIGURE 12. RTOS ‘Hello World’ (seven tasks shown).
Demo 4 “Hello World” —
Using PIC32 DMA
FIGURE 13. DMA demo.
We’ll now demonstrate a different “Hello World” using
the DMA controller to refresh the LED matrix. Here, we are
servicing all 35 LEDs where each LED is individually
controlled using the DMA in conjunction with the digital
I/O and timer. The I/O port is configured to drive all rows
and columns of the LED matrix for 35 individual LEDs.
These individual LED patterns are stored as a 1500 word C
array (LED_PATTERN) in Flash. DMA allows us to bypass the
CPU and transfer directly to the I/O port. The DMA
transfers occur as part of a timer 23 (32-bit timer)
peripheral interrupt (which occurs every 10 milliseconds).
DMA updates the LEDs with the specific array pattern
synchronized to this interrupt. This demo is DMA.MCP and
is also available for download. The demo creates a
dynamic light show with individual control of 35
LEDS to display random patterns between a
distinct “d,” “M,” “A” display on the LED matrix
(Figure 15). The main code is shown in Figure 14
and draws heavily on the DMA peripheral library.
Note the final loop. All of the DMA activities occur
while the CPU is simply executing the original
blinky “Hello World” demo. This is truly a powerful
demonstration of the PIC32 DMA.
microcontrollers. The PIC32 is currently recognized as one
of the best in its class, so what’s a better way to get
started than with 32-bit microcontrollers? It leverages off of
your 16-bit Experimenter experience. A lot of what was
learned and covered during the 16-bit series is still pertinent
There will be a lot of ground to cover to help realize
efficiency with this new technology. Given the expandability
of the Experimenter, there are many ways to realize this
potential. In upcoming articles, we hope to pave the way
with directions to USB, Ethernet, speech, and high
resolution graphics to name a few. NV
FIGURE 15. DMA ‘Hello World’ demo.
The Experimenter represents a
new, affordable, and exciting way of
getting involved with 32-bit
A complete kit to go
with this article can be
purchased online from
the Nuts & Volts
or call our order desk
FIGURE 14. DMA ‘Hello World’ code.
February 2011 63