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