TG9541 / stm8ef

STM8 eForth - a user friendly Forth for simple µCs with docs
https://github.com/TG9541/stm8ef/wiki
Other
311 stars 66 forks source link

Make the EXTI-TIM4 serial interface compatible with STM8L #319

Closed TG9541 closed 4 years ago

TG9541 commented 4 years ago

A proof-of-concept is in the repo STM8 eForth STM8L051LED.

Here are some requirements for the solution:

  1. STM8 eForth should be easier to configure and apply Note: aggregate EXTI-TIM4 code to a few central files that can be takren into board folders if necessary
  2. all GPIOs capable of EXTI shall be supported Note: this means using the bit patterned EXTI0..EXTI7
  3. interrupt vectors should be easier to manage Note: remove dummy code from boardcore.inc
  4. the simulated serial should at least work in full-duplex mode (sser-fdx) with STM8L051F3 Note: the code should be modular and sound but testing specific configurations can be done in applications
  5. it should be possible to add half-duplex (sser_hdx) and other STM8L devices later on Note: this optional
TG9541 commented 4 years ago

At least on the STM8L051F3 sser_hdx also works. The optional "point 5." will thus be met.

TG9541 commented 4 years ago

While I was at it I made TIM4_ARR and TIM4_PSCR configuration items and tested baud rates higher than 9600 baud using the simulated serial interface. This is what worked:

Rate CTIM4ARR CTIM4PSCR sser-fdx sser-hdx
600 7 0xCF yes* yes*
1200 6 0xCF yes* yes*
2400 5 0xCF yes* yes*
4800 4 0xCF yes yes
9600 3 0xCF yes yes
19200 2 0xCF yes yes
38400 1 0xCF yes yes
57600 1 0x89 (yes) yes
115200 0 0x89 no (yes)

*) untested but very likely to work - due to a 4 bit pre-scaler index STM8L devices can also use 300, 150, 75 downto 2.34375 baud - maybe that's useful for communication with a flashlight ;-)

Full-duplex at 115200 baud was too much for the combined TIM4 Rx/Tx state machine, and it stopped working. 115200 with half-duplex worked fine (using the new "-r" option of codeload.py, see #320) but I didn't test it with e4thcom since the baud rate in version 0.8.0.64 appears to be limited to 57600.

To be safe I would suggest limiting the usage of the simulated serial in full-duplex to 38400 baud and in half-duplex to 57600 baud.