SPI slave not always sending data
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-03-17 01:22 PM
Hi,
I'm using an STM32F429 Discovery board and having an issue with the FW_F4_V1.25.2 firmware. I have SPI3 configured as a full-duplex slave (currently used only to send) which sends data out to a Beaglebone as a Master. The Beagle supplies a 16MHz clock and SS to the Disco board. The clock is pulsed/polled every 2ms to get the header after which the data is clocked through, this loops.
My issue is that every so often the MISO pin stays low after the header is correctly sent and no data is clocked though, as verified on an oscilloscope. This seemingly happens at random, sometimes it may be once every 100 or so transfers and other times happens after just a few transfers.
I tried the latest FW_F4_V1.26.0 and don't seem to have this problem. However in this version the discovery board sometimes stops responding to the Beagle clock altogether and the HAL_SPI_Transmit command times out repeatedly until eventually it starts to work again at random and sends data.
As a side note, I don't understand why I need to specify 2 words as highlighted in the code below, in order to actually just clock through one of them. If I specify 1 word, no data is ever clocked through. However in the case of the header, 4 does mean four words are clocked though..
My transfer routine below is simple.
HAL_SPI_Init(&hspi3);
if (hspi3.State != HAL_SPI_STATE_BUSY_TX)
{
HAL_SPI_Transmit(&hspi3,(uint8_t*)&header,4,50);
}
if (hspi3.State != HAL_SPI_STATE_BUSY_TX)
{
HAL_SPI_Transmit(&hspi3,(uint8_t*)&data,2,50);
}
HAL_SPI_DeInit(&hspi3);
-------------------------------------------------------------------------------------------------------------
hspi3.Instance = SPI3;
hspi3.Init.Mode = SPI_MODE_SLAVE;
hspi3.Init.Direction = SPI_DIRECTION_2LINES;
hspi3.Init.DataSize = SPI_DATASIZE_16BIT;
hspi3.Init.CLKPolarity = SPI_POLARITY_LOW;
hspi3.Init.CLKPhase = SPI_PHASE_1EDGE;
hspi3.Init.NSS = SPI_NSS_HARD_INPUT;
hspi3.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi3.Init.TIMode = SPI_TIMODE_DISABLE;
hspi3.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
hspi3.Init.CRCPolynomial = 10;
Please could anyone help with this?
Thanks
- Labels:
-
SPI
-
STM32F4 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-03-17 11:41 PM
> I have SPI3 configured as a full-duplex slave (currently used only to send) which sends data out to a Beaglebone as a Master. The Beagle supplies a 16MHz clock and SS to the Disco board.
How does your wiring look like ?
SPI are low-energy digital connections, intended for onboard connection, i.e. the same PCB.
Try a lower speed, at least one order of magnitude less.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-03-18 09:58 AM
The cables are quite short, about 10cm so it should be okay. I have tested slower clock speeds and it actually performs much worse with each issue within each firmware. I think the problem lies somewhere else but not sure where?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-03-21 05:22 PM
I don't have the problem of the MISO pin staying low at random, when I increase the number of data words sent.
Can anyone help please?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-03-29 06:06 AM
I've played around with the GPIO parameters and this hasn't helped. I can see everything looks fine on the scope, it's just the MISO line doesn't respond to the clock sometimes?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-03-30 12:27 PM
Anyone.. ??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-03-30 12:57 PM
Debug as usually - instrument your code and observe its execution path. Observe error codes returned by Cube, work with the timeouts. Check, if the MISO pin goes threestate or hard low. Drop Cube, write your own code.
JW