Thank you Richard, I will try your suggestions today. I just started working with the STM8L because it has so many additional features, and is stingy on power consumption as well. Yes, 16MHz clock to TIM4.I have reset the interrupt flag in the ISR, and yes, I toggle a GPIO pin in the interrupt. I also don't see the Routing Interface or SYSCFG making a difference. Hope I'm not wrong. Thanks and Warm Regards Shiv
On Thursday, July 9, 2020, 07:43:45 PM GMT+5:30, Richard Hodges <rich...@hodges.org> wrote: On 2020-07-09 04:12, Shivakumar R via Sdcc-user wrote: > I run an interrupt at 125Hz on Timer2 in the STM8S chip that is not > taking place when I try to make it run on Timer4 in the STM8L chip . How do you verify this? Does your ISR toggle a pin or blink an LED? Since you already had the ISR working with timer2 on STM8S, I assume that your ISR clears the flag in the timer4 status register. > I've set the peripheral clock ON as an extra step in the STML, but am > not sure if there is any other step I'm missing. That looks correct. Are you using HSI with 16mhz going to timer4? The manual (RM0031, page 96) says to set the PCKEN bit before enabling the peripheral, and you do that. Maybe timer4 needs a few clock cycles before it is ready? You could test this by setting CLK_PCKENR1 earlier in the code. I don't think this is likely, but it would be easy to try. You could check that timer4 is running by reading the counter and writing it to PORTB. I don't think the "routing interface" has anything to do with this. I don't see anything interesting in the interrupt controller. I have been using STM8S, but this is the first time I have looked at STM8L. So I am also puzzled. All the best, -Richard > ------------------------------------------------------------------------------------------------------------- > > And this is in my STM8L initialization code that does not work properly: > ---------------------- > //set the STM8L051 clk TIM4 enable bit > #define TIM4CK 2 > > //Enable TIM4 CLK > CLK_PCKENR1 |= (1 << TIM4CK); > > /* Prescaler = 256 */ > TIM4_PSCR = 0b00001100; //prescaler for TIM4 to make it 4096 > /* Frequency = F_CLK / (2 * prescaler * (1 + ARR)) > * = 16 MHz / (2 * 4096 * (1+243)) = 8 Hz */ > > TIM4_ARR = 243; // The ARR value for 16MHz clk > > TIM4_IER |= (1 << TIM4_IER_UIE); // Enable Update Interrupt > > TIM4_CR1 |= (1 << TIM4_CR1_CEN); // Enable TIM4 > > __asm__("rim\n");
_______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user