2018-07-29 11:03 PM
I have been using a STM8S105 successfully for a few months and recently, I have been experiencing problems with i/o on UART2. When I eventually probed the NRST pin I noticed that there is a sawtooth waveform on that pin, with no other circuit connected to the NRST pin.
Has anyone seen this before and/or has an idea what is causing this? I am wondering if the MCU is executing bad code and which is causing it to reset - but why a sawtooth?! No watchdog is enabled.
2018-07-30 02:36 PM
Maybe an illegal opcode?
You can put a while (1) in the interrupt handler
2018-07-31 02:01 PM
Does the waveform change if an aggressive pull-up is added to NRST circuit?
2018-11-28 03:05 PM
Hi Robert
Could you find the solution to your problem? I'm facing the same trouble.
Any suggestion is welcome
2018-11-30 12:30 PM
Hi Daniel, it has been a while, but I believe I concluded that the MCU was executing an illegal opcode (as nestor suggested) as at that time I was writing my own small-C compiler for the STM8S and I noticed that there was a bug in the code generated that would cause the MCU to jump to the wrong location on reset under some conditions.
I would suggest that you write some simple code to show that the symptom does not appear and progressively include more and more of the code you are using. What I did myself was to move a loop in the body of main() until I found a point where the STM8S stopped behaving as expected. If UART is part of the problem the loop toggles an IO line but if UART is working, the loop includes both toggling an io line and echoing anything coming in on the UART, that way I can use a logic analyser (you can get a cheap one on aliexpress) and/or a serial terminal to find out at what point the trouble appears.
Please let me know what you find.