by Crossware
26. August 2014 18:12
Here is the simplest example C program we can devise for toggling the LEDs on the ADSP-CM408F EX-KIT Lite Board.
All LEDs are on Port E. By default the LEDs are enabled and so the soft switched do not need to be configured. Only the GPIO directions need to be set to make them outputs.
#include "xstdsys.h"
#define DELAY 100000
#define LED1PIN 7
#define LED2PIN 6
#define LED3PIN 5
#define LED4PIN 9
main()
{
// the following four lines could be combined into one if desired
g_pPORTE->DIR_SET = 1 << LED1PIN; // set as output
g_pPORTE->DIR_SET = 1 << LED2PIN; // set as output
g_pPORTE->DIR_SET = 1 << LED3PIN; // set as output
g_pPORTE->DIR_SET = 1 << LED4PIN; // set as output
while (1)
{
for (volatile int i = 0; i < DELAY; i++);
g_pPORTE->DATA_SET = 1 << LED1PIN;
for (volatile int i = 0; i < DELAY; i++);
g_pPORTE->DATA_CLR = 1 << LED1PIN;
for (volatile int i = 0; i < DELAY; i++);
g_pPORTE->DATA_SET = 1 << LED2PIN;
for (volatile int i = 0; i < DELAY; i++);
g_pPORTE->DATA_CLR = 1 << LED2PIN;
for (volatile int i = 0; i < DELAY; i++);
g_pPORTE->DATA_SET = 1 << LED3PIN;
for (volatile int i = 0; i < DELAY; i++);
g_pPORTE->DATA_CLR = 1 << LED3PIN;
for (volatile int i = 0; i < DELAY; i++);
g_pPORTE->DATA_SET = 1 << LED4PIN;
for (volatile int i = 0; i < DELAY; i++);
g_pPORTE->DATA_CLR = 1 << LED4PIN;
}
}