Looking in the examples of FWlib from ST in TIM2 PWM frequency Configuration, I don't understand how those numbers come out.I've read the read me file in the folder but seems wrong to me. In particular I would like to produce a square waveform of frequency 125kHz and duty cycle of 50%. I'm using a STM8S103F 20pin QFN package. I was trying to start with the FWLIB from ST with timer2. Can some one advise me how to? Thank's for all the support! Franco
discrete.st.com/stonline/products/literature/an/14054.pdf timers of STM8S103 have more features of the other STM8S family timers, I think that on STM8S103 you have timer5 (see RM) instead of timer2, so timer5 has different register map of timer2. coluber
Thank's for the reply. I just want to generate a square wave at 125kHz and duty cycle at 50%. Nothing more. I just want to use The timer2 output compare interrupt but doesn't seem so linear in using it. Thank's in advace frupi
Another question is: I'm using the internal HSI clock (16Mhz) and fmaster is 16Mhz(prescaler 2^0)is this the clock going in the TIM2 peripheral or not. I don't understand where the 2 Mhz come out, there is no reference in the manual about it. Ciao frupi
Thank's for the suggestions!!! I will give it a try and come back to you with result. By the way here is the interrupt that I'm using: void TIM2_CAP_COM_IRQHandler (void)interrupt 14 { if (TIM2_GetITStatus(TIM2_IT_CC1) != RESET) { TIM2_ClearITPendingBit(TIM2_IT_CC1); capture = TIM2_GetCapture1(); TIM2_SetCompare1( (capture + (UINT16)CCR1_Val) ); } Can you confirm if this is right!! Thank's in advance A drink is offered to you!! Cheers!
are you sure timer2 of stm8s103 is the same of timer2 of stm8s207? If I look at the datasheet of the two products I can see different register mapping. What am I missing? coluber
Frupi, The HSI is selected as default clock source;) Regarding the CLK block diagram: the fHSI is divided by the prescaler that can be configured through HSIDIV[1:0] bits in the CLK_CKDIVR register (the reset value for these bit is 1 so, it divide the fHSI/4 by default) for more details refer to reference manual. When you use the mode output compare PWM1 you don't need to configure the interrupt. Coluber, Yes, the timerx(x=1,2,3,4,5) when available on the product (refer to product datasheet) is the same as the described one in the STM8S microcontroller family reference manual. Regards mozra