STM32F4 SPI Send Error Condition
Added by leonard euler almost 2 years ago
Hi folks, My blockset version waijung_18.11a, Matlab R2020a.
My setup is
Hardware -> STM32F407G-DISC1 SPI Master and sensor is SPI Slave.
Matlab Config -> SPI Module 1 , SPI Mode CPOL_HIGH CPHA_2Edge , 8bit/ FirstBit_MSB . Baud rate 328125 Hz.I also use slave select mode
SS:A4 SCLK:A5 MISO:A6 MOSI:A7
I can be able to send first command and receive data succesfully.(also checked with logic analyzer).But when i tried to send second command with another SPI Master Read/Write block , it didn't send second command and Status pins becomes high.
When i checked it with logic analyzer i just saw first command related things.
I also put a delay between two SPI Master Read/Write block . But result not changed ,(succesfully sent first command , fail second command)
how can i solve this prbolem?
(Deep debug )
For determine the SPI error code.I dedicated to setup below steps
I sent the SPI command from .c file within Basic Custom Code Block, without SPI Master Read/Write1 block.
Just put this blocks for the matlab model 1) Target Setup1 2) UART Setup 3) SPI Master Setup1 4) Basic Custom Code Block(send SPI code )
I created a chart for execute sequentially 1) run Basic Custom Code Block 2) run stm32f4_usart(Non-blocking)
After i just sent one command. i succesfully got a respond from sensor as before i explaned. But SPI_FLAG_MODF(Mode Fault) and SPI_I2S_FLAG_TXE(this flag expected i think this is not create a problem) was set.
After i tried to send two commands . SPI_FLAG_MODF flag set, i just saw first command from logic analyzer