cancel
Showing results for 
Search instead for 
Did you mean: 

stm32f4 spi issue

mburumaxwell
Associate
Posted on January 21, 2015 at 22:37

I recently bought the STM32F429I-DISCO and less than one month down the line am beginning to get disappointed.

I connected AT45DB041D to it via SPI5 and the last bit of almost every byte was misbehaving. Either it is set on not set. Reading the ID of the chip gave me 0x1F (atmel) and 0x25(8Mbit) yet the chip is 4Mbit. I tried out with LPC4337 which I was using for another project and it turned out to be okay giving 0x1F and 0x This last bit corruption occurred everywhere except when reading the status register. On googling I found these links:

/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/STM32F4%20SPI%20Communication%20-%20Last%20MISO%20Bit%20not%20received&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=96

/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/STM32L053%20Nucleo%20-%20SPI%20Issue&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=8

[DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/STM32%20SPI%20Spoiled%20Bits&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&TopicsView=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/AllItems.aspx?Paged%3DTRUE%26p_StickyPost%3D%26p_DiscussionLastUpdated%3D20141010%252021%253a14%253a50%26p_ID%3D46804%26View%3D%257bF47A9ED8%252dE726%252d42BE%252dACED%252d732F13B66581%257d%26FolderCTID%3D0x012001%26PageFirstRow%3D41&currentviews=64]link3 I tried out and yes using SPI2 or even SPI3 wrks perfectly. However, SPI1, SPI4 and SPI5 all resulted in corrupted data. Here is the part I called in my code:

uint8_t buff[4];
int
main(
void
) {
/* MCU Configuration----------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_SPI5_Init();
buff[0] = 0x9F;
AT45_ENABLE();
HAL_SPI_Transmit(&hspi5, buff, 1, 1000);
HAL_SPI_Receive( &hspi5, buff, 4, 1000);
AT45_DISBALE();
while
(1) {
}
}

The code was generated using STM32CubeMX. Anyone please help me solve this issue? #stm32f4 #discovery #spi #!stm32f4-disco #error
2 REPLIES 2
childresss
Associate II
Posted on January 22, 2015 at 06:46

I use CubeMX->IAR for an STM32F415.

The SPI1 port goes to a wireless radio. Works fine.

I have to remember, in CubeMX, to change the clock frequency for the SPI to much lower than the CubeMX default. The '415 is 168MHz so the default SPI clock is about 40MHz. I run the clock at 5 or 10 MHz. With an SPI flash chip, you might push it to much higher, but I'd start at 10MHz.

Posted on January 22, 2015 at 10:08

Please post the content of RCC and SPI registers after having received a faulty byte.

Could you also post the complete code, maybe packing up the project?

Thanks,

JW