I’m a beginner in LPC1768 & freertos development, so I hope I could get some help for my project
I’m using freeRTOS LPC1768 rowley crossworks demo as base config for my project. I’ve modified the code by removing all demo tasks except for the flash.c and uIP task, and added my own PWM code to the project
the issue was that both of the flash.c and uIP task work perfectly, however my PWM are not working. I’ve configured for the PWM to be channeled to on-board LED. From debugging, it seems that the PWM is initialized, but never run. Below is the PWM code:
LPC_SC->PCONP |= 1 << 6; // enable power for PWM1 LPC_SC->PCLKSEL0 |= 1 << 12; //PCLK = CCLK = 64MHz LPC_PWM1->PR = 64 - 1; //prescale to obtain 1MHz LPC_PINCON->PINSEL4 = (LPC_PINCON->PINSEL4 & ~(0x3 << 0)) | (0x1 << 0); //output to pin 2.0 (LED 11). From this, the LED is turned off,showing initilization are taking place LPC_PINCON->PINMODE4 = (LPC_PINCON->PINMODE4 & ~0x3) | 0x2; //no pull-up/down LPC_PWM1->MR0 = 20000; /*set clock cycles for PWM. PWM freq = PCLK/MR0 (?)*/ LPC_PWM1->MR1 = 1500; // pulse width 1.5ms LPC_PWM1->LER = (1 << 0) | (1 << 1); //Apply changes to MR LPC_PWM1->MCR |= 1 << 1; // interrupt on match0.Reset timer on Match0; LPC_PWM1->PCR = (1<<9); //set output to PWM1 LPC_PWM1->TCR = (1<<0)|(1<<3); //reset & enable counter }
when I’m not using freeRTOS, the PWM would already run after the LPC_PWM1->TCR = (1<<0)|(1<<3); line…
however, with freeRTOS, the PWM doesnt run after LPC_PWM1->TCR = (1<<0)|(1<<3); line…
any idea on whats happening?
really appreciate any help.thank you in advance