cancel
Showing results for 
Search instead for 
Did you mean: 

Wait states

maestr0
Associate
Posted on July 05, 2011 at 12:55

Hi,

I have question regarding STM8S wait states. When exactly wait states are executed - every access to XFLASH or every instruction feed?

I want to clock my MCU with 24Mhz crystal oscilator (1 wait state) and I need to know what will be the speed gain in comparison with 16MHz clock (0 wait states). How much instructions are cycle acurate while wait states are on? I cant find any information on this topic.

Thanks,

Pawel

1 REPLY 1
fggnrc2
Associate II
Posted on July 05, 2011 at 14:51

Pawel,

clocking the STM8 core to 24 MHz may improve performance, but the real gain changes from application to application and must be measured with an oscilloscope because the STM8 pipeline and the 32 bit wide bus of XFLASH muddle any clock cycle count.

When the core is running at 24 MHz, XFLASH can't respond to STM8 core so quickly. A wait state is therefore needed.

When a wait state is added, each XFLASH access takes about 83 ns @ 24 MHz, but this slowdown may not impact performance, as four bytes are returned.

If your code consists in small footprint opcodes (eg. one-byte instructions like INC A, MUL X,A DIV X.Y etc) there is no real XFLASH performance penalty since a XFLASH data fetch provide enough data to the STM8 decode pipeline and this penalty is averaged on at most four instructions.

When XFLASH isn't a bottleneck, there is a sure gain in processing speed but this gain, as I wrote before, depends on your code.

In my opinion, if you need more computing power, you may choose a STM32 or if you need only small speed improvements, you can recode your algorithms.

You can also execute your code from RAM (which doesn't need a wait state), but doing so the code and data pipelines must share the same bus which is only 8 bit wide.

In my opinion, a 16 MHz clock is a better choice.

Regards,

EtaPhi