2006-04-06 03:06 AM
Speed of PWM generated from 32khz clock
2006-04-02 05:21 AM
Hi:
I'm trying to generate 1800Hz out of the timer1 PWM output with 32khz internal clock(RTC clock). I learn that the max output that i could generate was close to 1100Hz. Is there any theoretical explanation for this limit? If there is something I'm doing wrong, please direct me with the right direction (code)... Regards,2006-04-05 09:17 AM
In order to get an 1800 Hz signal from a 32 kHz clock, you need a full output cycle every 17.7778 timer ticks. The closest integer is 18 which will give you a frequency of 1777.78 Hz. This means for a 50% duty cycle wave you need a transition every 9 ticks.
Assuming that you are using the 710 set up the timer this way: Because the clock resets to FFFC, you need to subtract 4 from the timer tick value for the total length Set the prescaler to 0 (divide by 1) Set OCBR to 14 Set OCAR to 5 (or other value between 0 and 14 to set the pulse width) Set up the OLVLA and OLVLB bits to select which part of the wave form has logic high level. In the TIM1_CR1 register ... Set OCAE to enable output on the pin Set PWM to enable PWM output Set EN to start the clock As an alternitave, if you want a fixed 50% duty cycle wave, set both OCAR and OCBR to 5.2006-04-06 03:06 AM
Hi:
Thanks for the information. I used the setting recommended by you and was getting close to 1800hz. I would use the same math to generate the other frequencies for DTMF(1633,1477,1336,1209,941,852,770,697Hz).I understand that 5 is being subtracted in the library(tim.c) if we use the TIM_PWMOModeConfig() routine to set the parameters for the timer. So, 4 shouldn’t be subtracted for calculating the OCAR and OCBR. Again, thanks for the help.