AnsweredAssumed Answered

STM8S - SPI not working after power-on reset (yes, it strange)

Question asked by korol.oleg on Mar 19, 2012
Latest reply on Feb 10, 2013 by rossi.hwang
I trying to develop device using STM8S105K6 MCU and found something very strange.

If I press reset button (connecting NRST to GND) all if working fine.
But If I just turn off/on device power, MCU is starting (timer is working, LED is flashing, and so on), but SPI is not working (to be more exact, it not clears TXE flag).

This is my code for init:
     SPI_CR1_bit.BR = 1;
     SPI_CR1_bit.MSTR = 1;
     SPI_CR1_bit.CPOL = 0;
     SPI_CR1_bit.SPE = 1;

This is a little bit later in main:
         SPI_DR = 0x55; // test
         while (!SPI_SR_bit.TXE) { // here we got infinite loop :(
               PB_ODR_bit.ODR5 = 1;
               PB_ODR_bit.ODR5 = 0;
          }
 
If I do manual reset, all is starting to work fine. But If I just turn power off/on, it goes to infinite loop inside WHILE (and I can see this by oscilloscope by changing voltage on PB5 pin).

Another fact: If I will heat MCU by soldering iron or soldering station - it starting to work, but then it makes cold, and not working again.

Where is my problem (I hope not in my DNA :)?
What I should do to get stable working of MCU?

Thanks in advance!

Outcomes