Jump to content

YSN

Members
  • Content Count

    3
  • Joined

  • Last visited

  1. YSN

    Interface MSP432 with MPU6050

    I removed the 10k resistors as I read online that the sensor has 4.7k resistors on board. Progress: Initially, the problem is solved if I turn off the sensor and turn it back on. Then I am able to cycle through the 14 data registers once. But when I send the stop and then restart at the address of the first register (0x3B) to be read, the code gets stuck at polling for TXIFG.
  2. YSN

    Interface MSP432 with MPU6050

    Hi Antscran, yes I have cross checked the address (0x68). I will use a lower value resistor for pulling the SDA and SCL lines. Unfortunately, I don't have access to a scope. But please find the attached code. I am using the Driver library for MSP432. Code: #include "driverlib.h" #include "i2c.h" #include <stdint.h> #include <stdio.h> #include <stdbool.h> #include <string.h> #define SLAVE_ADDRESS 0x68 #define NUM_OF_REC_BYTES 14 const uint8_t TXData[16] = {0x6B,0x00,0x3B,0x3C,0x3D,0x3E,0x3F,0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48}; static uint8_t RXData[NUM_OF_REC_BYTES]; static volatile bool stopSent; unsigned int ctr=0; const eUSCI_I2C_MasterConfig i2cConfig = { EUSCI_B_I2C_CLOCKSOURCE_SMCLK, // SMCLK Clock Source 3000000, // SMCLK = 3MHz EUSCI_B_I2C_SET_DATA_RATE_100KBPS, // Desired I2C Clock of 100khz 0, // No byte counter threshold EUSCI_B_I2C_NO_AUTO_STOP // No Autostop }; int main(void) { MAP_WDT_A_holdTimer(); MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1, GPIO_PIN6 + GPIO_PIN7, GPIO_PRIMARY_MODULE_FUNCTION); stopSent = false; memset(RXData, 0x00, NUM_OF_REC_BYTES); /* Initializing I2C Master to SMCLK at 100kbs with no autostop */ MAP_I2C_initMaster(EUSCI_B0_MODULE, &i2cConfig); /* Specify slave address */ MAP_I2C_setSlaveAddress(EUSCI_B0_MODULE, SLAVE_ADDRESS); /* Set Master in transmit mode */ MAP_I2C_setMode(EUSCI_B0_MODULE, EUSCI_B_I2C_TRANSMIT_MODE); /* Enable I2C Module to start operations */ MAP_I2C_enableModule(EUSCI_B0_MODULE); //Enable master Receive interrupt MAP_I2C_enableInterrupt(EUSCI_B0_MODULE, EUSCI_B_I2C_TRANSMIT_INTERRUPT0); MAP_Interrupt_enableInterrupt(INT_EUSCIB0); MAP_Interrupt_enableMaster(); while (MAP_I2C_masterIsStopSent(EUSCI_B0_MODULE) == EUSCI_B_I2C_SENDING_STOP); while (I2C_isBusBusy(EUSCI_B0_MODULE)==EUSCI_B_I2C_BUS_BUSY); MAP_I2C_masterSendMultiByteStart(EUSCI_B0_MODULE, TXData[0]); while (I2C_isBusBusy(EUSCI_B0_MODULE)==EUSCI_B_I2C_BUS_BUSY); MAP_I2C_masterSendMultiByteFinish(EUSCI_B0_MODULE, TXData[1]); ctr=2; while (1) { MAP_I2C_masterSendMultiByteStart(EUSCI_B0_MODULE, TXData[ctr]); MAP_I2C_enableInterrupt(EUSCI_B0_MODULE, EUSCI_B_I2C_TRANSMIT_INTERRUPT0); while(!stopSent); ctr++; if (ctr==16) { ctr = 2; } stopSent = false; } } void euscib0_isr(void) { uint_fast16_t status; status = MAP_I2C_getEnabledInterruptStatus(EUSCI_B0_MODULE); MAP_I2C_clearInterruptFlag(EUSCI_B0_MODULE, status); if (status & EUSCI_B_I2C_TRANSMIT_INTERRUPT0) { printf("sent\r\n"); MAP_I2C_disableInterrupt(EUSCI_B0_MODULE, EUSCI_B_I2C_TRANSMIT_INTERRUPT0); MAP_I2C_setMode(EUSCI_B0_MODULE, EUSCI_B_I2C_RECEIVE_MODE); MAP_I2C_masterReceiveStart(EUSCI_B0_MODULE); MAP_I2C_enableInterrupt(EUSCI_B0_MODULE, EUSCI_B_I2C_RECEIVE_INTERRUPT0); } if (status & EUSCI_B_I2C_RECEIVE_INTERRUPT0) { int i=ctr-2; RXData[i] = MAP_I2C_masterReceiveMultiByteNext(EUSCI_B0_MODULE); printf("%d\r\n",RXData[i]); RXData[i] = MAP_I2C_masterReceiveMultiByteFinish(EUSCI_B0_MODULE); MAP_I2C_disableInterrupt(EUSCI_B0_MODULE, EUSCI_B_I2C_RECEIVE_INTERRUPT0); MAP_I2C_setMode(EUSCI_B0_MODULE, EUSCI_B_I2C_TRANSMIT_MODE); stopSent = true; } } Your help is much appreciated. Thank you.
  3. Hi, I am having trouble interfacing the MSP432 with MPU6050. I have pulled the SDA and SCL lines up to 3.3V with 10k resistors. When I initiate the communication using the I2C_masterSendMultipleByteStart(), the program enters an infinite loop waiting for the TXIFG to be set after the STT is sent. I can see that the STT remains set and TXIFG never gets set. What could be the issue? Please let me know if you want me to post the code. Thank you.
×