You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi have used stm8s103 in sduino , i cannot able to write ISR for timer2 please help
INTERRUPT_HANDLER(TIM2_UPD_OVF_IRQHandler, 13) /* TIM4 UPD/OVF */
{
}
void TIM2_Config(void)
{
//set at 100usec on overflow aims
/* TIM2 configuration:
TIM2CLK is set to 16 MHz, the TIM2 Prescaler is equal to 16 so the TIM2 counter
clock used is 16 MHz / 16 = 1000 000 Hz
With 1000 000 Hz we can generate time base:
max time base is 65536us if TIM2_PERIOD = 65535 --> (65535 + 1) * 1000000 = 65536 us
min time base is 2 us if TIM2_PERIOD = 1 --> ( 1 + 1) * 1000000 = 2 us
In this example we need to generate a time base equal to 256 us
so TIM4_PERIOD = (0.001 * 125000 - 1) = 124 */
/* Time base configuration /
TIM2_TimeBaseInit(TIM2_PRESCALER_16, TIM2_PERIOD);
/ Clear TIM4 update flag /
TIM2_ClearFlag(TIM2_FLAG_UPDATE);
/ Enable update interrupt */
TIM2_ITConfig(TIM2_IT_UPDATE, ENABLE);
Well.. yesterday I've spent like half the day to find this out while trying to get timer 2 interrupts to work... (well I can only blame myself for not checking github issues after that much time).
So it guess interrupt vectors must be declared in all translation units so in in case of sduino they must be uncommented in the stm8s_it.h file where all those declarations live... but are commented out. Then it's possible to define them in own code in any translation unit that includes stm8s_it.h (with the same name and interrupt vector number) and everything works as it should.
I don't understand why those declarations are commented out, especially why are they only commented out for SDCC and not for other compilers. I've checked builds with original file and uncommented declarations and leaving them in doesn't change the binary in any way. I've got linker errors from some vectors though that I had to keep commented out:
?ASlink-Warning-Undefined Global '_CLK_IRQHandler' referenced by module 'main'
?ASlink-Warning-Undefined Global '_TLI_IRQHandler' referenced by module 'main'
?ASlink-Warning-Undefined Global '_SPI_IRQHandler' referenced by module 'main'
?ASlink-Warning-Undefined Global '_AWU_IRQHandler' referenced by module 'main'
?ASlink-Warning-Undefined Global '_EEPROM_EEC_IRQHandler' referenced by module 'main'
?ASlink-Warning-Undefined Global '_TRAP_IRQHandler' referenced by module 'main'
?ASlink-Warning-Undefined Global '_TIM1_UPD_OVF_TRG_BRK_IRQHandler' referenced by module 'main'
?ASlink-Warning-Undefined Global '_ADC1_IRQHandler' referenced by module 'main'
This was tested with build for STM8S003, using sduino in PlatformIO (sduino version 0.5.0, platformio stm8 package version 2.1.0)
Activity
dirkx commentedon Feb 19, 2025
Having the same issue - and notice that the entry for the interrupt function does not seem to be made in the interrupt table:
For similar trivial code:
dirkx commentedon Feb 19, 2025
Confirmed that this indeed requires
to be uncommented in
sduino/sduino/stm8/cores/sduino/stm8s_it.h
Line 150 in 0ce7e4c
I guess what we need here is something like a '__weak' compiler trick. Or something fundamentally different when linking.
sajadkkkkkk commentedon Nov 13, 2025
**hello i had same problem
by changning interrupt vector 13 to 15 , it solved for me .
my microntroller is stm8s105k6
best regards.**
sajadkkkkkk commentedon Nov 13, 2025
my ide is IAR
halfrafu commentedon Mar 28, 2026
Well.. yesterday I've spent like half the day to find this out while trying to get timer 2 interrupts to work... (well I can only blame myself for not checking github issues after that much time).
So it guess interrupt vectors must be declared in all translation units so in in case of sduino they must be uncommented in the
stm8s_it.hfile where all those declarations live... but are commented out. Then it's possible to define them in own code in any translation unit that includesstm8s_it.h(with the same name and interrupt vector number) and everything works as it should.I don't understand why those declarations are commented out, especially why are they only commented out for SDCC and not for other compilers. I've checked builds with original file and uncommented declarations and leaving them in doesn't change the binary in any way. I've got linker errors from some vectors though that I had to keep commented out:
This was tested with build for STM8S003, using sduino in PlatformIO (sduino version 0.5.0, platformio stm8 package version 2.1.0)