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
  • Thanks Stian. After giving this some thought, because my goal is to get up and running as quick as possible, I'm going to try to leverage the 4k lines of code that Rowberg has written (referenced above on Github). While this may take me away from the nRF chip, based on what I'm finding, I think there would be considerable interest from the developer community in a forking of Rowberg to the nRF 51 series so I just wanted to pass this along. While the learning is fun and I obviously have a long way to go, I also need to leverage what experienced developers have done if I'm going to get anywhere -- I'm already too old for this as it is :)

Reply
  • Thanks Stian. After giving this some thought, because my goal is to get up and running as quick as possible, I'm going to try to leverage the 4k lines of code that Rowberg has written (referenced above on Github). While this may take me away from the nRF chip, based on what I'm finding, I think there would be considerable interest from the developer community in a forking of Rowberg to the nRF 51 series so I just wanted to pass this along. While the learning is fun and I obviously have a long way to go, I also need to leverage what experienced developers have done if I'm going to get anywhere -- I'm already too old for this as it is :)

Children
No Data
Related