cancel
Showing results for 
Search instead for 
Did you mean: 

SPI master interrupt issue

vignesh1
Associate III

Recently working with spi communication in stm32g070rb using stm32CubeIDE (HAL library).SPI master receive interrupt triggered continuosly when there is no interrupt.But same code wrote in SPI slave its works perfectly.I also put Pull down resistor

so My main problem is if i configure SPI master Spi rx callback automatically triggered again and again. Slave devices that rx callback function works perfectly. I think if any master mode fault what reason master spi interrupt triggered unwantedly

i have also one doubt if any did not connect miso,mosi,sclk pins to slave devices. i just load the code to master device then i see interrupt rx callback or error occurs. pls provide solution

 

This code works properly in full duplex slave if i set full duplex master or half duplex master does not works

my clock configuration is set(hopefully correct) i do not use slave select pin for i set this software(one master and one slave) and also give interrupt priority why this only woks slave not master devices

 

int main(void)

{

HAL_Init();

SystemClock_Config();

HAL_SPI_Receive_IT(&hspi1,spi_data,1);

while (1)

{

}

}

 

void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi)

{

HAL_SPI_Receive_IT(&hspi1,spi_data,1); // ready for new interrupt

}

1 ACCEPTED SOLUTION

Accepted Solutions

I don't know how to say it any differently than before: Only the master can initiate a transfer. This is true in blocking, interrupt, and DMA modes.

You can use a different pin to signal to the master that the slave has data, but that would be handled outside of the SPI protocol.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

5 REPLIES 5
TDK
Guru

The master sends the clock on SPI in order to receive a byte. Your program is continuously receiving bytes and therefore continuously sending a clock signal. No bugs there.

Perhaps you are expecting it to behave like UART, which it does not.

If you feel a post has answered your question, please click "Accept as Solution".

if master spi clock is enabled SPI in order to receive a byte at the start of the program , will it receive the data anytime sent by the slave device.Give your answer and above answer now i understand thanks for service 

No, that's not how SPI works. Only the master can initiate a data transfer. The slave has to wait for the master to send clocks before it can send data.

https://en.wikipedia.org/wiki/Serial_Peripheral_Interface

 

 

If you feel a post has answered your question, please click "Accept as Solution".

Thanks for your valuable solution.I was confusion about spi communication now i realise what mistake i made(Mater device receive interrupt does not works) Is correct ??.Continue ur valuable services 

I don't know how to say it any differently than before: Only the master can initiate a transfer. This is true in blocking, interrupt, and DMA modes.

You can use a different pin to signal to the master that the slave has data, but that would be handled outside of the SPI protocol.

If you feel a post has answered your question, please click "Accept as Solution".