gicking / STM8-SPL_SDCC_patch

Patch for STM8 Standard Peripherals Libraries
Apache License 2.0
88 stars 13 forks source link

help on stm8s Tim4_TimeBase on stm8s-discovery #3

Closed aguegu closed 6 years ago

aguegu commented 6 years ago

I have been trying the patched SPL on stm8s-discovery.

I can not get the stm8s Tim4_TimeBase example working on my both stm8s-discovery. I have simplified the demo even more. All I want is PD0 led blinking on timer4 overflow interrupt handler. It looks like that the handler did not get executed and the chip will reset several times (print dozens of "hello") then halt.

https://github.com/aguegu/stm8demos/tree/f2a9bc48f471768c5970b7d902ce1fcd4529a9a2/stm8s-discovery/blink_spl_i

My sdcc version is 3.7.0

gicking commented 6 years ago

hello aguegu,

welcome to the team, I also stumbled across this SDCC "feature": as described in section 3.8.1 in SDCC reference SDCC requires the interrupts to be also declared in the file containing main() --> just add "#include "stm8s_it.h" to the top of main.c. At least for SDCC 3.6.0 this fixed the bug. Let me know if this solves your issue.

Have a nice day! :-)

Georg

aguegu commented 6 years ago

Ha, thank you for your response. Adding "#include "stm8s_it.h" to the top of main.c did solve the problem!

Thank you for your direction. I think I got a lot of "features" to learn about.

I have upgraded my demo code: https://github.com/aguegu/stm8demos/tree/master/stm8s-discovery/blink_spl_i

I wish the community grow faster and bigger. Then problem like this can be easily googled or found on stackoverflow. :+1:

aguegu commented 6 years ago

@gicking How about add patch to the main.c file in the project template folder?

gicking commented 6 years ago

hello aguegu,

good idea! Just uploaded the new patch

Georg