Hi,
I'm using the Olimex LPC2378-STK board and have successfully implemented some minor tasks.
The next goal was to configure a task to initialize PWMs.
The periodic function to be executed is as follows, note all the constants are defined (or added) to the LPC23XX.h file:
#define Period 0x4E40
#define MS 0x3E9
extern void fnInitializePWMs(int *ptrTaskTable)
{
fnDebugMsg("In Initialize PWMS \n\r");
//Configure the appropriate pins such than Pin 50,53,54,57 are PWM 3,4,5,6 respectively
PINSEL3 |= 0x00228800;
//PINSEL3 &= 0xFFDDBBFF;
//Set the pins mentioned above as outputs
//IO1DIR |= 0x06A00000;
//PCLK for use with the PWMs is set to be 1/4 the input processor clock speed
PCLKSEL0 |= (00 << 12);
//Timer Mode for PWM TC, Use the Prescale counter
//PWM1CTCR Should read all 0's
PWM1CTCR &= 0xF0;
//Create a 50Hz clock with 20ms period
PWM1MR0=Period;
//All these are bullshit initial values that should be changed at some point
PWM1MR3=MS;
PWM1MR4=1.5*MS;
PWM1MR5=2*MS;
PWM1MR6=1.5*MS;
//Single edge output for PWM 3,4,5,6. Enable said PWMs
PWM1PCR = 0x00007800;
//Enable the PWM Timer Counter and Enable PWMs
PWM1TCR=0x09;
}
Of course, the next lines of code were added to the TaskConfig.h file.
#define TASK_PWM_INITIALIZATION 'z' //Initialze PWM
extern void fnInitializePWMs(TTASKTABLE *);
//The next line was added into ctNodes[]
ASK_PWM_INITIALIZATION, //PWM initialization task
//The next line was added into the ctTaskTable[]
#ifdef TASK_PWM_INITIALIZATION
{ "z Initialize the PWMs", fnInitializePWMs,NO_QUE,(DELAY_LIMIT)(2*SEC),0,UTASKER_STOP}, //test task
#endif
This task executes once, but I see no PWMs on the appropriate pins. The PWM pin initialization code, however, does work perfectly if declared as an extern void InitializePWMs(void) function and having the main function call the initialization procedure before entering an infinite while loop all the while never entering utasker scheduling code.
I am left to conclude that something the utasker does wipes out my initialization procedure and continues to do so even if the initialization task is set to be periodic. I was wondering if anyone could lend me a hand.
Thanks,
Kirk