Part Number: LAUNCHXL-F28379D
Hi,
I'm trying to get data from the MPU6050, but it wont show anything in the plot. I'm using Altair Embed, and with another Launchpad F28377S it worked.
Don´t know if the I2C communication with this Launchpad is screwed or something.
The connection I'm doing is :
SDA - GPIO104 - Pin10(J1)
SCL - GPIO105 - Pin9(J1)
I will show the code Embed generates
/*** Altair Embed 2019.0.1 Build 41 Automatic C Code Generator ***/
/* Output for FC.vsm at Thu Nov 14 20:13:22 2019 */
/* Target: F280X[F28379cpu1] */
#include "math.h"
#include "cgen.h"
#include "cgendll.h"
#include "c2000.h"
#include "vsi2c.h"
int MHZ=200;
#define _SYS_MHZ_ 200
SERIAL_QUEUE_DECL(16) i2cRx0 = {16,0,0,0,0,0,0,0,0};
SERIAL_QUEUE_DECL(16) i2cTx0 = {16,0,0,0,0,0};
extern int _i2cMaxFifo=4;
static CGDOUBLE gxs= 0;
static CGDOUBLE fcang= 0;
static CGDOUBLE _xf_state17[1]={ 0};
static CGDOUBLE _xf_Xdot_17;
/* Init */
static void subsystem3()
{
if (1)
i2c0PutChar( 107 );
if (1)
i2c0PutChar( 0 );
if (1)
{
I2CSARA = 0x68; // Set Slave Addr
I2CCNTA = 0x2; // Set msg len
I2CMDRA = 0x2E20; // Start Tx
}
}
static void subsystem37(void);
static SIGNAL _vsOutSig37[8]={{T_SCALED_INT,.u.scaledInt={16,16,0}}, {T_SCALED_INT,.u.scaledInt={16,16,0}}, {T_SCALED_INT,.u.scaledInt={16,16,0}}, {T_SCALED_INT,.u.scaledInt={16,16,0}}, {T_SCALED_INT,.u.scaledInt={16,16,0}}, {T_SCALED_INT,.u.scaledInt={16,16,0}}, {T_SCALED_INT,.u.scaledInt={16,16,0}}, {T_SCALED_INT,.u.scaledInt={16,16,0}}};
static SIM_STATE tSubsystem37={0,0,0
,0,0,0,8,0,0,0,0,1,1,1,0,0,0,0,0,_vsOutSig37};
SIM_STATE *hSubsystem37=&tSubsystem37;
/* read_data */
static void subsystem37()
{
hSubsystem37->outSigS[0].u.scaledInt.val = i2c0GetChar(&i2cRx0);
hSubsystem37->outSigS[1].u.scaledInt.val = i2c0GetChar(&i2cRx0);
hSubsystem37->outSigS[2].u.scaledInt.val = i2c0GetChar(&i2cRx0);
hSubsystem37->outSigS[3].u.scaledInt.val = i2c0GetChar(&i2cRx0);
hSubsystem37->outSigS[4].u.scaledInt.val = i2c0GetChar(&i2cRx0);
hSubsystem37->outSigS[5].u.scaledInt.val = i2c0GetChar(&i2cRx0);
hSubsystem37->outSigS[6].u.scaledInt.val = i2c0GetChar(&i2cRx0);
hSubsystem37->outSigS[7].u.scaledInt.val = i2c0GetChar(&i2cRx0);
}
static CGDOUBLE _xf_state84[1]={ 0};
static CGDOUBLE _xf_Xdot_84;
static CGDOUBLE _xf_state83[1]={ 0};
static CGDOUBLE _xf_Xdot_83;
static CGDOUBLE _xf_state59[1]={ 0};
static CGDOUBLE _xf_Xdot_59;
static void subsystem53(void);
static SIGNAL _vsOutSig53[1]={{T_DOUBLE,0}};
static T_SIG_SCALED_INT _inSig_53_1={T_SCALED_INT,16,16,0};
static T_SIG_SCALED_INT _inSig_53_2={T_SCALED_INT,16,16,0};
static T_SIG_DOUBLE _inSig_53_3={T_DOUBLE,0};
static T_SIG_SCALED_INT _inSig_53_4={T_SCALED_INT,16,16,0};
static SIGNAL* _vsInSig53[]={
(SIGNAL*)&_inSig_53_1, (SIGNAL*)&_inSig_53_2, (SIGNAL*)&_inSig_53_3, (SIGNAL*)&_inSig_53_4};
static SIM_STATE tSubsystem53={0,0,0
,0,0,4,1,0,0,0,0,1,1,1,0,0,0,0,_vsInSig53,_vsOutSig53};
SIM_STATE *hSubsystem53=&tSubsystem53;
/* Controller_block */
static void subsystem53()
{
static CGDOUBLE _Y_59=0;
static int _squareCnt90=0;
float t74;
float t75;
static CGDOUBLE _Y_84=0;
float t77;
static CGDOUBLE _Y_83=0;
_Y_59 = _xf_state59[0];
t74 = ((CGDOUBLE) (short)hSubsystem53->inSigS[0]->u.scaledInt.val);
t75 = ((CGDOUBLE) (short)hSubsystem53->inSigS[1]->u.scaledInt.val);
_xf_Xdot_84 = (((( simAtan2(((((((double) t74)+-169.2))*6.103515625e-05)), (0.+((((((double) t75)+-21))*6.103515625e-05)))))))*57.295779513082 /* radians => degrees */)- _xf_state84[0]*-0.99;
_Y_84 =_xf_Xdot_84*0.01;
t77 = ((CGDOUBLE) (short)hSubsystem53->inSigS[3]->u.scaledInt.val);
gxs = ((((((double) t77)+456.))*0.0076335877862595));
_xf_Xdot_83 = gxs - _xf_state83[0]*-0.99;
_Y_83 =_xf_Xdot_83*0.00396;
fcang = ( _Y_84+ _Y_83);
if ((++_squareCnt90 > 125?(_squareCnt90>=250?_squareCnt90=0,1:1):0))
{GPASET = 0x2000L;}
else
{GPACLEAR = 0x2000L;}
if (((int) _Y_59))
{GPCSET = 0x800000L;}
else
{GPCCLEAR = 0x800000L;}
hSubsystem53->outSigS[0].u.Double = fcang ;
_xf_state84[0] = _xf_Xdot_84;
_xf_state83[0] = _xf_Xdot_83;
_xf_Xdot_59 = (1.+ -( _Y_59));
_xf_state59[0] = _xf_Xdot_59;
}
static SIGNAL _vsOutSig2[1]={{T_DOUBLE,0}};
static ARG_DESCR outArgInfo2[]={
{ T_DOUBLE,0,0,0},
};
static ARG_DESCR inArgInfo2[]={
0};
static SIM_STATE tSim={0,0,0
,outArgInfo2, inArgInfo2,0,1,0,0,0,0,1,1,1,0,0,0,0,0,_vsOutSig2};
SIM_STATE *sim=&tSim;
/* MPU */
INTERRUPT void cgMain()
{
static CGDOUBLE _Y_17=0;
int t34;
static unsigned _pulseCnt53=2;
TIMER2TCR = TIMER2TCR;
_Y_17 = _xf_state17[0];
if (((I2CA_RX_QUEUE_LEN(i2cRx0))>=1) )
{ /* read_data */
subsystem37();
}
t34 = (( hSubsystem37->outSigS[4].u.scaledInt.val << (short)8)+ hSubsystem37->outSigS[5].u.scaledInt.val);
if ((++_pulseCnt53 > 1?_pulseCnt53=0,1:0) )
{ /* Controller_block */
hSubsystem53->inSigS[0]->u.scaledInt.val = (( hSubsystem37->outSigS[0].u.scaledInt.val << (short)8)+ hSubsystem37->outSigS[1].u.scaledInt.val);
hSubsystem53->inSigS[1]->u.scaledInt.val = (( hSubsystem37->outSigS[2].u.scaledInt.val << (short)8)+ hSubsystem37->outSigS[3].u.scaledInt.val);
hSubsystem53->inSigS[2]->u.Double = ((((CGDOUBLE) t34)*0.0029411764705882)+36.53);
hSubsystem53->inSigS[3]->u.scaledInt.val = (( hSubsystem37->outSigS[6].u.scaledInt.val << (short)8)+ hSubsystem37->outSigS[7].u.scaledInt.val);
subsystem53();
}
if (1)
i2c0PutChar( 61 );
if (1)
{
I2CSARA = 0x68; // Set Slave Addr
I2CCNTA = 0x1; // Set msg len
I2CMDRA = 0x2620; // Start Tx
}
if (((int) _Y_17))
{
I2CSARA = 0x68; // Set Slave Addr
I2CCNTA = 0x8; // Set msg len
I2CMDRA = 0x2C20; // Start Rx
}
;
sim->outSigS[0].u.Double = hSubsystem53->outSigS[0].u.Double;
_xf_Xdot_17 = (1.+ -( _Y_17));
_xf_state17[0] = _xf_Xdot_17;
endOfSampleCount = TIMER2TIM;
if (TIMER2TCR&0x8000)
setTgtStatus(VE_STAT_TGT_OVER_FRAMING);
}
void main()
{
EALLOW;
SYSPLLCTL1 = 0;
CLKSRCCTL1 = 2; //Internal Osc 1
CLKSRCCTL2 = 0; //Internal Osc 2
SYSPLLMULT = 0x14; // set PLL to 20xOSC = 200 MHZ
SYSPLLCTL1 = 1; // Enable PLL
while(!(SYSPLLSTS&1)); // Wait for PLL lock
{ int divSel;
for (divSel =63; divSel >= 0; divSel--)
{ SYSCLKDIVSEL = divSel; // Ramp up freq
SysCtlDelay(15);
}
}
SYSPLLCTL1 = 3; // Use PLL
PERCLKDIVSEL = 0x10;
PCLKCR0 = 0x20;
PCLKCR1 = 0x1;
PCLKCR9 = 0x1;
EDIS;
hSubsystem37 = cgInitSubsystem(hSubsystem37, &tSubsystem37);
hSubsystem53 = cgInitSubsystem(hSubsystem53, &tSubsystem53);
simInit( &tSim );
EALLOW;
GPADIR = 0x2000;
GPACSEL1 = 0x22222222;
GPACSEL2 = 0x22022222;
GPACSEL3 = 0x22222222;
GPACSEL4 = 0x22222222;
GPBQSEL1 = 0xF00000;
GPBCSEL1 = 0x22222222;
GPBCSEL2 = 0x22222222;
GPBCSEL3 = 0x22222222;
GPBCSEL4 = 0x22222222;
GPCDIR = 0x800000;
GPCCSEL1 = 0x22222222;
GPCCSEL2 = 0x22222222;
GPCCSEL3 = 0x2222222;
GPCCSEL4 = 0x22222222;
GPDMUX1 = 0x50000;
GPDPUD = 0xFFFFFCFF;
GPDCSEL1 = 0x22222222;
GPDCSEL2 = 0x22222200;
GPDCSEL3 = 0x22222222;
GPDCSEL4 = 0x22222222;
GPECSEL1 = 0x22222222;
GPECSEL2 = 0x22222222;
GPECSEL3 = 0x22222222;
GPECSEL4 = 0x22222222;
GPFCSEL1 = 0x22222222;
GPFCSEL2 = 0x22222222;
EDIS;
I2CPSCA = 50;
I2COARA = 0; // Set own address
I2CCLKLA = 10;
I2CCLKHA = 5;
I2CMDRA = 0x20; // Take I2C out of reset
I2CFFTXA = 0x4000; // Reset TX FIFO
I2CFFTXA = 0x6000; // Enable TX FIFO
I2CFFRXA = 0x64; // Reset RX FIFO
I2CFFRXA = 0x2064; // Enable RX FIFO
startSimDsp();
installInterruptVec( 8, 2, &i2c0rx_isr);
ENABLE_PIE_INT(8);
subsystem3(); /* Init */
installInterruptVec(-2,7,&cgMain);
TIMER2PRD = 0x1a80; // 32-bit Timer Period Low
TIMER2PRDH = 0x6; // 32-bit Timer Period High
TIMER2TCR |= 0x4020; //Interrupt enable, Timer Reset
EALLOW;
PIECTRL = 1; // Enable PIE Interrupts
EDIS;
IER |= 0x2000; //CPU Interrupt enable
resetInterrupts();
disable_interrupts(); // Disable interrupts until PC handshake complete
EALLOW;
PCLKCR0 |= 0x80000; // Start all PWM timers
EDIS;
dspWait();
}
I know it might be a pull-up resistors problem, but it haven't worked either, also when you try to get the signal from the SCL and SDA ports with an Oscilloscope, it won't even show a noisy signal.
If you could help me, I'd be very thankful
Thanks in advance.