2018-07-05 07:53 AM
Hi every one I have problem in spi communication , I want to Send and
Receive
data with loopback(mosi connects to miso) in stm32f103c8t6 by interrupt . I set this settings in stm32cube : clock 8m, prescaler 128 ,,,.......in IDE I use this code:
.
.
.
uint8_t tx[13]={'aliyazdanifar'};
uint8_t rx[13];HAL_StatusTypeDef a,b;.
.
void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi)
{
while(1);
}
void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi)
{
}
.
.
.
a=HAL_SPI_Receive_IT(&spi1,rx,13);
b=HAL_SPI_Transmit_IT((&spi1,tx,13);
.
.
while(1)
{}
when I debug this code ,I have (a=hal_ok,b=hal_busy,) and spi is not work.
What should I doØŸ
2018-07-05 04:01 PM
HAL_SPI_Receive_IT(&spi1,rx,13); // this will force 13 bytes to be clocked into the SPI1Rx buffer,
So now, I guess the HAL unit is busy. clocking in 13 bytes..
then you run this: HAL_SPI_Transmit_IT((&spi1,tx,13)
? I guess you are waiting for the receive to finish before you can transmit.
2018-07-05 06:32 PM
if you had 2 SPI ports, one set to master and one set to slave.
take the master clock to the slave clock,
take MOSI from master to MISO of Slave,
then run you existing code, both DMAs should work.
2018-07-06 02:44 AM
yes, your saying is correct , but the same of this code runs correctly for uart , but about spi does not work . that's a surprise for me