Skip to main content
ABhat.7
Associate III
August 9, 2021
Question

LL Driver based Spi not working in stm32f3 using stm32cubelibrary version 1.1.3

  • August 9, 2021
  • 2 replies
  • 1164 views

hi,

i am trying to run mcp2515 with stm32f303k8 board i am successfully done with hal but when trying the same function in LL it data register is get some garbage value along with the data attached is my code and logic analzyer pics i do not unerstand why it is happening i am using polling method clear seen in the code.

attached is my code,.ioc file please support in this

@Ons KOOLI​ 

This topic has been closed for replies.

2 replies

TDK
August 9, 2021

You can't read a byte on SPI without sending anything. Just waiting and then reading DR won't do anything useful.

 uint8_t TM_SPI_Read(SPI_TypeDef* SPIx)
 {
	uint32_t i;
uint8_t dataIn=0;
uint8_t dummy=0;
	/* Check if SPI is enabled */
	SPI_CHECK_ENABLED(SPIx);
 
	/* Wait for previous transmissions to complete if DMA TX enabled for SPI */
	SPI_WAIT(SPIx);
 
 
		/* Fill output buffer with data */
		//SPIx->DR = dummy;
 
		/* Wait for SPI to end everything */
		SPI_WAIT(SPIx);
 
		/* Save data to buffer */
		dataIn = SPIx->DR;
 
		return dataIn;
}

"If you feel a post has answered your question, please click ""Accept as Solution""."
ABhat.7
ABhat.7Author
Associate III
August 9, 2021

I have tried that also I just uncomment spi_dr = dummy where I am sending 0 but still I am receiving garbage data I saw on logic analyzer that transmit is working fine but evertime I received garbage value ​