This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

TWI and MPU6050

Hi,

I've been searching the devzone for TWI examples, and preferably an example with MPU6050. Here are a conclusion of stuff that I found, but as some of them were for 2013/2014 wanted to check first that no updated versions are available:

  • It seems the TWI example has been removed after SDK 6, but the drivers are still there. I'm using SDK 9 for PCA20006 (Beacon module).

  • There are twi_hw_master.c and twi_sw_master.c in drivers_nrf folder, which it seems the hw one doesn't work with Softdevice, but sw one works. Don't know what are the pro and cons of hw and sw.

  • In devzone.nordicsemi.com/.../ Alseth has provided a file named sd_twi_hw_master.c which seems will solve the issue with Softdevice. This was originally posted 2 years ago and re-uploaded one year ago. Don't know if the problem has been solved in future releases.

  • I can see a file named nrf_drv_twi.c in the twi_master folder, which was not mentioned in any of the posts that I looked at. Is this a new addition?

  • There are drivers specifically for MPU6050 as explained in devzone.nordicsemi.com/.../ that provide init, write, read, and verify product id.

My goal is read data every 50msec from the sensor and then advertise them whenever they fill a full packet.

Considering those functions provided in MPU6050 drivers, should I just go through the registers of MPU6050 and write the correct values to them by using the WRITE function, and then just read with READ function and save data? Meaning that I do not need to face writing any code for TWI and...?

Any other setting required?

Thanks, FA

Parents
  • Hi.

    The old twi_hw_master.c and twi_sw_master.c are legacy drivers. There has been a lot of confusion around these drivers as they have changed a bit over time to accommodate for a few erratas found in the 1st and 2nd revision of the nRF51. I'm not sure what chip revision is on your particular beacon, but you can compare the chip markings with the compatibility matrix to find out.

    If you have the 3rd revision IC then you should use the new TWI drviers found in SDK 9. They are the ones called nrf_drv_twi.c. Here is a "getting started example" for these drivers.

    I'm not really sure if I understand your last question, but you will need to write to registers to set up and start up the MPU. And you will basically need to go through the registers in the MPU data sheet one-by-one to figure out which bits in the registers to be sets. Time consuming, yes, but it needs to be done.

  • I checked all the 5 modules I got June 2015 from Digikey and all of them are CE AA D0, which means Rev. 2. It would be great if you let me know how I can get Beacon modules with 3rd revision chips as ultimately I should use that revision. However, if there isn't a way to know the revision before receiving the modules, can you please comment on what I asked about the file Alseth provided in devzone.nordicsemi.com/.../. Based on that post it seems SDK 6 drivers can not work with the SoftDecive.

Reply
  • I checked all the 5 modules I got June 2015 from Digikey and all of them are CE AA D0, which means Rev. 2. It would be great if you let me know how I can get Beacon modules with 3rd revision chips as ultimately I should use that revision. However, if there isn't a way to know the revision before receiving the modules, can you please comment on what I asked about the file Alseth provided in devzone.nordicsemi.com/.../. Based on that post it seems SDK 6 drivers can not work with the SoftDecive.

Children
No Data
Related