When Timer0 interrupts and PWM are used at the same time. The timing is not correct.
void timer_init(void)
{
set_tmr_enable(CLK_PER_REG_TMR_ENABLED);
set_tmr_div(CLK_PER_REG_TMR_DIV_8);
timer0_init(TIM0_CLK_FAST, PWM_MODE_ONE, TIM0_CLK_NO_DIV);
timer0_register_callback(Timer0_IRQ_Handle);
timer0_set(1500, 900, 100);
timer0_enable_irq();
timer0_start();
}
timer0_set(1500, 900, 100);
The height and low of PWM is correct,900=450us , 100=50us。
The interruption time is incorrect ,1500=750us ,The actual time is 1000us。
Device:
Hi Wally,
In DA14580, the ON counter interrupt is dependent on the HIGH and LOW values of the PWM due to the fact that the register operation to reload the ON conter value (1500 in this case) has to wait until the Timer register LOW value has reached to zero. Let's say when the ON counter reached 0 when the Timer PWM0 is in the middle of LOW count, the ON counter stays at 0 until the PWM0 has reached 0 on the LOW count and then generates the interrupt. To keep things consistent, it is recommended to configure the HIGH LOW values such that the sum of HIGH and LOW is always equal to ON value. Hope this helps. Please refer to the document snippet below.
Best,
LC_Dialog
Hi! LC.
Could you upload the whole document or tell us the reference number of the document you quoted?
谢谢!
Hi bemoon,
This information is from full specification of the DA14580 SoC and it is not available to provide it.
Thanks, PM_Dialog
Thank you for your reply.
Hi bemoon,
Adding to PM_Dialog's comment, you might find this information in our DA14585 Datasheet. This module on DA14580 is similar to the one on DA14585. So you might use that docuemnt for reference.
Please note that not all the other modules might be similar though.
Best,
LC_Dialog
Thank you very much LC.
It's really useful!