سلام دوستان
من يک برنامه نوشتم که توي اون ابتدا PWM با يک فرکانس کار مي کنه و بعد از سه ثانيه بايد فرکانسش عوض بشه . ولي اين اتفاق رخ نمي ده به نظر شما مشکل کجاست :
کد:
/************************************************************************************ Code created using the ARMwizard, visit http://alexan.edaboard.eu
************************************************************************************/
#include <LPC17xx.h>
void delay (unsigned long tick) { /* Delay Function */
unsigned long dly = tick*300;
while(dly--);
}
int main(void)
{
LPC_PINCON->PINSEL3 = 0x00000800; /* binary: 00000000_00000000_00001000_00000000 */
LPC_SC->PCONP = (LPC_SC->PCONP & 0xEFEFF7DE) | (1UL<<6); /* Enable peripheral clock for PWM1 (default is enabled) */
LPC_PWM1->MCR = 0x00000002; /* binary: 00000000_00000000_00000000_00000011 */
LPC_PWM1->MR0 = 0x0016E360; /* decimal 1500000 */
LPC_PWM1->MR3 = 0x000186A0; /* decimal 100000 */
LPC_PWM1->CTCR = 0x00; /* binary: 00000000 */
LPC_PWM1->PCR = 0x00000800; /* binary: 00000000_00000000_00001000_00000000 */
LPC_PWM1->TCR = 0x09; /* binary: 00001001 */
while(1)
{
delay(3000);
LPC_PWM1->MR0 = 0x0007A120;
}
}
با تشکر