2023-12-01 09:40 AM
Hello,
I've configured SPI1 on STM32H742VIT6 connected to pins PA4-7 using AF5.
Here is a dump of the relevant SPI1 registers:
SPI1->CR1 = 00000001
SPI1->CR2 = 00000000
SPI1->CFG1 = 70000007
SPI1->CFG2 = 20400000
SPI1->SR = 00001002
The MCU should be the SPI master and I am trying to control the NSS output as follows (NSS is on PA4):
__INLINE void bsp_spi_nss_assert(void)
{
GPIOA->BSRR = GPIO_BSRR_BR4;
}
__INLINE void bsp_spi_nss_release(void)
{
GPIOA->BSRR = GPIO_BSRR_BS4;
}
I find that the NSS signal is asserting though and remains low forever (so I don't think the bsp_spi_nss_release function is working).
Can someone recommend anything to try which I might be missing?
Thanks!
-Brian
Solved! Go to Solution.
2023-12-05 06:48 AM
Hello All
It seems there is data in the RX FIFO that has not been read yet. However, the DXP and RXP bits being set indicate that the SPI peripheral is currently receiving data.
Have you tried without using SD Card?
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-12-05 10:58 AM
Hello,
I solved one problem I was having. I understood that the RXWNE flag is only set after I have transmitted 4 bytes. Since I am trying to do SPI send/receive one byte at a time, the correct flag to use to initiate a read seems to be RXP instead of RXWNE. So I have modified my bsp_spi_read_byte() function as follows:
__INLINE uint8_t bsp_spi_read_byte(void)
{
uint8_t data;
while (!(SPI1->SR & SPI_SR_RXP));
data = *(uint8_t *) &SPI1->RXDR;
bsp_spi_nss_release();
return data;
}
So far this is working better. I still need to debug some final problems related to reading from SD card.
Thanks,
-Brian