2019-10-01 06:46 AM
Can anyone post any code that can help me here please, or suggest me how to move forward
2019-10-03 10:58 PM
I think you are aware of the synchronous nature of SPI. Meaning, the first byte the slave sends while you transmit is meaningless and has to be discarded.
> while(!(USART1->STATUS & USART_STATUS_TXBL)); //while this is not true, transmit buffer not empty
I don't know your MCU (EFR32), but assuming ST-like semantics, "transmit buffer empty" means the value to send had been moved to the output register, but not that the SPI transaction is finished. You would need to check with the serial/SPI section of the EFR32 manual.
With STM32 parts, the Tx register is an interface for the core. A Tx register value is transferred to the actual transmission hardware when no other transaction is ongoing. Transmission then takes the time required according to the interface's configuration. A completed transmission finally sets a flag in the status register.
2019-10-04 10:18 AM
I think you are aware of the synchronous nature of SPI. Meaning, the first byte the slave sends while you transmit is meaningless and has to be discarded. -
By this do you mean value it is reading from who am i register is meaningless and to be discarded
2019-10-04 11:24 AM
Thank you for your reply, do you mean to say the data i am reading from who am i register is meaningless and basically i am not receiving from who am i register
2019-10-06 10:53 PM
The byte you receive while clocking out the address value (register offset) is meaningless.
This is the nature of SPI. To returning some meaningful answer, the slave has to receive the "command" first - i.e. the R/W bit and the address. Synchronous SPI clocks out whatever happens to be in the slave's TX register at that time. With the second byte, the slave is able to fetch the requested register and copy it to the SPI TX register.
That's what the datasheet implicitly says with the SPI diagrams.
2019-10-10 09:57 AM
is there any sample code for this particular acclerometer, as I haven't been able to solve it
2019-10-11 01:22 AM
Hi @RNata.15 , I unfortunately don't have experience with silicon lab efr32, and I believe you should request support also to Silicon lab. What I can suggest you are the STMems_Standard_C_drivers for LIS2HH12 you can find here. Regards