SPI slave 1 bit shift after power on
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-02-05 1:12 PM
Hi, I'm working with a STM32F446ZET6. In this case, I configured my SPI as slave, and I use the HAL_SPI_TransmitReceive function.
The problem is that when the slave shoud respond with the value 0x11, I receive 0x22 on the master side.
I have checked the send value with a logic analizer and it shows that the slave is sending 0x22 (not 0x11). But this only happens when the programm starts from power on.
When I reset manually (NRST button on STM) the board I don't have this problem. It only happends from power on.
I have no idea of what the issue is.
Thanks in advance for the help.
Solved! Go to Solution.
- Labels:
-
SPI
-
STM32F4 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-02-06 11:56 AM
hello
Seems like some transient pulse during power on in clock line is tranlsated as slave clock input after slave initialization and "listening"
A workaround for this case is to enable slave SPI after the master device is powered and initialized.
Note that CPOL and CPHA (polarity and phase) of clock signal must be the same on both devices.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-02-06 4:36 AM
Probably during powerup/reset/start the SCK lines toggles unwanted. Perhaps proper external pull up/down can help. Consider also that HAL may cause the unwanted clock.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-02-06 11:56 AM
hello
Seems like some transient pulse during power on in clock line is tranlsated as slave clock input after slave initialization and "listening"
A workaround for this case is to enable slave SPI after the master device is powered and initialized.
Note that CPOL and CPHA (polarity and phase) of clock signal must be the same on both devices.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-02-08 7:48 AM
Thank you your answers.
Yes, I have checked the spi mode (CPOL and CPHA) is the same on both master and slave.
And i Have pull-up on the clock and CS signal.
It works from power on when I delay the SPI slave initialization. Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-02-08 7:52 AM
But as I'm able to detect this error, is it possible to reset the SPI so as to not have this shift?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-02-08 11:12 AM
Yes SPI may be reset from RCC_APBxRSTR register , (SPIxRST) bit but
needs initialization again.
