How to read sensor's registers using SPI?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to read sensor's registers using SPI?

3,659 Views
Amit_Kumar1
Senior Contributor II

Hi

I am using code warrior with PE. And FRDM-K20D50M board, I Want to read the "who_am_i register" of the FXOS87000CQ accelerometer-magnetometer  the address of the register is 0x0D. I am using SPI_Master_LDD component from PE I couldn't find any syntax for querying the registers. As WHO_AM_I is the easiest thing to read in any such ICs, After that I have to read the accelerometers and magnetometer's x,y,z values. but I am stuck in this. The receive blocks i.e SM1_ReceiveBlock(spipointer, rbuff, sizeof(rbuff)); doesn't have any bit field to read any register. Is there any sample code for handling the sensors using SPI ? Kindly look into the matter.

Regards

Amit Kumar

Labels (1)
5 Replies

1,472 Views
trytohelp
NXP Employee
NXP Employee

Hi Amit,

I've created a new thread following your last comments:

      https://community.freescale.com/thread/322753

I will ask info to other teams and will keep you informed via the new thread.

Regards

Pascal

1,472 Views
BlackNight
NXP Employee
NXP Employee

Hi Amit,

you might have a look at Review: New FRDM-KL26Z Board | MCU on Eclipse (search for FXOS8700): I wrote a driver and component which uses the WHO_AM_I register, so you can have a look at this example and driver.

I hope this helps,

Erich

1,472 Views
Amit_Kumar1
Senior Contributor II

Hi Erich

Thanks for the link, Actually I wanted to learn using SPI how can we read the registers? I have used this module in one of my project but it is i2c based. I have some others sensors also which is SPI based so for that I wanted to use SPI. If basic principle of making sensor work using SPI is clear then it will be easy for me as well as other forum members using them too.

Thanks & Regards

Amit Kumar

0 Kudos

1,472 Views
Amit_Kumar1
Senior Contributor II

Hi Erich

Thanks for the above links, From the 3rd link u provided, I got some pointers on how to work as there is a method created by you which says " uint8_t SPI_ReadRegister(uint8_t reg) " and similarly for write register. I tried to make it work but was not successful. I will again try using it. Any suggestions how to deal with it?

Thanks & Regards

Amit Kumar 

0 Kudos