cancel
Showing results for 
Search instead for 
Did you mean: 

I am using LIS2HH12 ACC, I am able to read the value of status registers and who am i REGISTER BUT NOT ABLE TO READ THE VALUE OF X, Y, Z REGISTERS, i am using a silicon lab efr32 radio board as dev board

RNata.15
Associate II

Can anyone post any code that can help me here please, or suggest me how to move forward

15 REPLIES 15
Ozone
Lead

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.

RNata.15
Associate II

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

RNata.15
Associate II

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

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.

RNata.15
Associate II

is there any sample code for this particular acclerometer, as I haven't been able to solve it

​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