2012-03-19 11:01 AM
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! #problem #reset #spi #stm8s2012-03-19 12:08 PM
Hmm..
I have tried to add ~5ms delay between initialization of MCU and SPI, and all started to work even in power-on sequence! I still not understand what happened and why. What is right workaround for this?2012-04-24 05:20 AM
Strange behaviour like this is often power supply related. If the problem occurs only when you cycle the power and is 'fixed' with a delay then the problem is related to the rise time of the power supply and/or power on reset of the device
2012-05-08 02:43 AM
Just try to connect 10kOm resistor between ground and SCK pin.
2013-02-10 02:02 AM