cancel
Showing results for 
Search instead for 
Did you mean: 

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

ABhat.7
Associate III

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​ 

2 REPLIES 2
TDK
Guru

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
Associate III

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 ​