Hi all,
I am facing issue after PWM generation . PWM is affecting other process.
My project is to count the number of pulses in an I/O pin and give warning according to the pulse rate.I am using CC2538 running at 32kHz, with sleep mode. The pulse rate in my case is 0-250 kHz. Threshold value is 75 kHz, so after 75 kHz i generate PWM to generate alarm tone in a speaker. PWM frequency is 1.5 kHz.
The processor will be in sleep for 5sec, then wakes-up and process the calculations and go to sleep mode again.
Till125 kHz with PWM ON iam getting the correct count. For 150 kHz with PWM ON, iam getting as 74 kHz. But for the same freq(150 kHz) with PWM OFF, i am getting the correct count. Till 250 kHz with PWM OFF, i am getting the correct count. But PWM ON is causing the issue.
I am counting the pulses in an interrupt handler and PWM is hardware driven. No interrupt for PWM. Single frequency(1.5 kHz) iam generating on PWM.
I am configuring GPTimer1 in PWM mode and just turning ON the Timer1.
The Timer Configuration code is :
void GPTimer1Init(void) { HWREG(IOC_GPT1OCP1) = IOC_MUX_OUT_SEL_GPT1_ICP1; SysCtrlPeripheralEnable(SYS_CTRL_PERIPH_GPT1); GPIOPinTypeTimer(GPIO_D_BASE, GPIO_PIN_0); IOCPinConfigPeriphOutput(GPIO_D_BASE, GPIO_PIN_0, IOC_MUX_OUT_SEL_GPT1_ICP1); TimerDisable(GPTIMER1_BASE, GPTIMER_BOTH); TimerIntDisable(GPTIMER1_BASE, 0); TimerConfigure(GPTIMER1_BASE, GPTIMER_CFG_SPLIT_PAIR | GPTIMER_CFG_A_PWM | GPTIMER_CFG_B_PERIODIC); HWREG(GPTIMER1_BASE + GPTIMER_O_CTL) |= 0x02; //freezes on halting TimerPrescaleSet(GPTIMER1_BASE, GPTIMER_A, 50); TimerPrescaleSet(GPTIMER1_BASE, GPTIMER_B, 200); TimerMatchSet(GPTIMER1_BASE, GPTIMER_A, 0x27FF); TimerLoadSet(GPTIMER1_BASE, GPTIMER_A, 0xFFF); HWREG(IOC_GPT1OCP1) = IOC_MUX_OUT_SEL_GPT1_ICP1; HWREG(GPTIMER1_BASE + GPTIMER_O_TAMR) &= ~(GPTIMER_TAMR_TAPWMIE); // TimerEnable(GPTIMER1_BASE, GPTIMER_A); }
The PWM generation is working fine. But it is affecting the High pulse count. Even in sleep mode PWM is generating.
Timer will be enabled on High pulse rate only.
Some Questios too-
- Isn't the PWM hardware driven or on timeout weather it affect the controller.