Login Register
TLSR8258 low performance issue
Jan 31, 2021 07:45




Just a simple use-case make me uncertain if i do everything correct.
I adjust system clock in tlsr8258 EVK to 48 MHz by modifying clock_init() as follows:

#define reg_mcu_clkseh REG_ADDR8(0x70)

_attribute_ram_code_ void clock_init(SYS_CLK_TypeDef SYS_CLK) {

reg_clk_sel = 0x20;


reg_mcu_clkseh = 0;

other untouched stuff



After that i remove any unnecessary code in main() after clock_init(), initialize GPIO C5 as output and run toggling in while(1).

With oscilloscope i see non-square pulses with low frequency of somewhat 20-30 usec log"1" and "0" durations (Optimization is -O2 as in all examples).
After playing around i ended up with ~60 kHz near-square pulses (8usec duration log"1" and "0") when directly write a byte to the output registers as follows:
#define MY_REG REG_ADDR8(0x593)
_attribute_ram_code_ int main (void) //must run in ramcode {
mcu and clock initialization

while(1) {

 MY_REG = 0xFF;

 MY_REG = 0;


The question is why the simple gpio toggle operation is so slow? Why does it takes 48x8~350 cpu cycles to write a single HW register value? Or maybe what i make wrong and how can we speed this up? It's also interesting that we obtain 2-3 times speed up by replacing gpio_toggle() line with lines above, just skipping a very simple bitmask operations on bytes that are performed inside gpio_toggle().
I know that PWM feature for toggling a pin is more proper way, but i'm here to obtain some idea about computation performance of tlsr825x generation.

1 replies
Fanis [Author] Feb 01, 2021 18:29

Well, OK. I carried new encouraging tests.
While leaving system clock frequency setup untouched as above (48 MHz) i setup timer irq using provided api and placed a gpio_toggle() to irq handler. 4us timer period shows pretty good square signal on scope with expected 125kHz frequency. While 2usec period seems slightly above cpu processing limits (here i suppose writing to gpio out register itself takes some usecs to finish) and results in unstable 160kHz pulses (whereas should be 300kHz).
It s still a little worse than i was expecting and 2-3 times slower, than cortex m0-m3 crystals that i tested with similar dummy toggling, but this should be enough for most applications.

However any experienced developer s comments on the issue will be appreciated.