Sorry for the silly question but which parameters to use when calling timer0_set(on, high, low) to get an interrupt every 0.5ms (2khz)? Same question for 0.1ms (10khz). Thanks
You can have a look at the peripheral examples\timer0\timer0_general and change the value timer0_set_pwm_on() from 20000 which is the RELOAD_100MS to just 20, this will set a reload value in your timer and your configuration should be T = 1/200kHz * 20 = 10kHz interrupt. You can also have different options to configure the interrupt frequency that you would like for example, use a different clock divider CLK_PER_REG_TMR_DIV_8 to a smaller division in order to feed the timer and dont use TIM0_CLK_DIV_BY_10 and use larger reload values.
Thank you for the reply. I have made changes as you have mentioned in your comment and it is working fine. But i have to use TIM0_CLK_DIV_BY_10 to make 10KHz frequency. Thank you so much.
Hello Rony,
我将送你一个example that can help here. It is based on a sounder which users timer0 to set the PWM frequecny..
In the example Timer0_set(on, high, low) does the following:
BR JE_Dialog
Thanks
Could you send me the same example .. I am looking for the same thing with 10Khz as well.
Could you send me that same example?? .. I am also looking for the same thing with 10Khz.
Hi Ruchi Patel,
You can have a look at the peripheral examples\timer0\timer0_general and change the value timer0_set_pwm_on() from 20000 which is the RELOAD_100MS to just 20, this will set a reload value in your timer and your configuration should be T = 1/200kHz * 20 = 10kHz interrupt. You can also have different options to configure the interrupt frequency that you would like for example, use a different clock divider CLK_PER_REG_TMR_DIV_8 to a smaller division in order to feed the timer and dont use TIM0_CLK_DIV_BY_10 and use larger reload values.
Thanks MT_dialog
Hey MT_Dialog,
Thank you for the reply. I have made changes as you have mentioned in your comment and it is working fine. But i have to use TIM0_CLK_DIV_BY_10 to make 10KHz frequency. Thank you so much.
Regards,
Ruchi