2021-08-09 02:48 AM
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
2021-08-09 06:14 AM
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;
}
2021-08-09 06:22 AM
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