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

MPU6050 to nRF51 DK

New to embedded world. Trying to interface MPU6050 w/ nRF51 DK via TWI. I have included the external MPU6050 drivers and everything compiles in Keil (except for last few lines of code below). Just need gyro data for x, y, z.

I have found related questions/material here and here but these don't specifically address my problem.

I have been able to get everything to work by duplicating hardware and code from github here but it's using a different MCU and I want to move to the nRF51 for ble capability.

Any help to solving my coding issue to get gyro output is greatly appreciated. Also, it appears this can be done either hardware or software TWI? Any advantage to one vs. the other?

  main.c
'#include "stdio.h"
'#include "simple_uart.h"
'#include <stdbool.h>
'#include <stdint.h>
'#include "nrf.h"
'#include "bsp.h"
'#include "mpu6050.h"
'#include "twi_master.h"
'#include "twi_master_config.h"

'#define MPU6050_ADDRESS (0x68U) 


int fputc(int ch, FILE * p_file)

{
      simple_uart_put((uint8_t)ch);

       return ch;
}
int main(void)
{
			//set up UART for output
      simple_uart_config(RTS_PIN_NUMBER, TX_PIN_NUMBER, CTS_PIN_NUMBER, RX_PIN_NUMBER, false);

       		
	   //Initialize TWI
	    twi_master_init();

     //initialize device
     mpu6050_init (MPU6050_ADDRESS);
					
		//verify conection
     mpu6050_verify_product_id();
	
	  			
		//Read data	& Output 		
	
	   while(1) {
		// mpu6050_register_read(MPU6050_ADDRESS,(0x68U), 156); //prototype - mpu6050_register_read(uint8_t register_address, uint8_t * destination, uint8_t number_of_bytes)
		   		
			      // printf - need gyro data only for x, y, z 
		 }
	}		
Parents
  • So, what exactly is not working? Does the mpu6050_verify_product_id(); return with anything meaningful? Is the TWI up and running? Are you able to see the bits on the TWI bus using a logic analyzer? What have you done already to debug the code? And what is the conclusion so far? Are you using a development kit, or custom hardware? Have you checked that the pinout is correct for your hardware setup?

    The software TWI was created for the first nrf51822 chip revision, since there was some hardware issues. This was corrected in the subsequent releases. So you should be fine using the TWI HW.

Reply
  • So, what exactly is not working? Does the mpu6050_verify_product_id(); return with anything meaningful? Is the TWI up and running? Are you able to see the bits on the TWI bus using a logic analyzer? What have you done already to debug the code? And what is the conclusion so far? Are you using a development kit, or custom hardware? Have you checked that the pinout is correct for your hardware setup?

    The software TWI was created for the first nrf51822 chip revision, since there was some hardware issues. This was corrected in the subsequent releases. So you should be fine using the TWI HW.

Children
No Data
Related