Close

Some more refactoring enables new use cases

A project log for eForth for cheap STM8S gadgets

Turn cheap modules from AliExpress into interactive development kits!

ThomasThomas 05/15/2020 at 07:400 Comments

From the start, STM8 eForth "background task" used TIM2. The consequence is that Timer2 Capture/Compare, e.g. for PWM, has to use the Background task repeat rate, a multiple of it, or otherwise disable the background task feature altogether. Sure, there are alternatives, e.g. Idle Task or low level interrupts, but these have different properties with respect to I/O or freedom-of-interference with the console.

Now I got a use-case where the frequency of the TIM2 PWM2 has to be completely free (1Hz to 150kHz), and still a normal background task is needed. Obviously the background task had to be moved to a different timer, e.g. TIM1 ( @Ivan Alf  I guess you'll recognize the code for the XY-LPWM board even if I changed it a bit :-) ).

Another use case where some hardware abstraction is necessary is the project #MODBUS Things with STM8 eForth : different STM8 devices use a first or a second address range and interrupt vector for the UART (or both). The UART name, however, depends on features and not the address. Since in most cases a common subset of features is sufficient new naming conventions provide a robust solution.

The required changes are in the current STM8 eForth 2.2.24.pre4 "beta".

Discussions