This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

PROBLEM TO READ FROM ACCELEROMETER CC3200 LAUNCH BOARD

Other Parts Discussed in Thread: CC3200

Hi to everybody ,

I have an error when I try to enable the accelerometer inside the board 

//Init Accelerometer Sensor
lRetVal = BMA222Open();
if(lRetVal < 0)
{
ERR_PRINT(lRetVal);
LOOP_FOREVER();
}

I put both jumper on the J2 (SDA) and J3 ( SCL) .

I need to do other things ??

  • Hi ,

    I am trying to use the I2C bus to read from the accelerometer.

    But I have an error here :

    //Init Accelerometer Sensor
    lRetVal = BMA222Open();
    if(lRetVal < 0)
    {
    ERR_PRINT(lRetVal);
    LOOP_FOREVER();
    }

    On teraterm I have the mistake in this part.

    What is the problem ? I can't read from the I2c..

  • Hi Luca,

    What is the status of J2/J3 jumpers? Please see the CC3200 Launch Pad user guide section 2.4.2 at: processors.wiki.ti.com/.../CC32xx_LaunchPad_Hardware

    Regards,
    Gigi Joseph.
  • Hi Gigi ,

    I put a jumber on j2 and j3..
    I think it is ok..
    it is correct ?

    Regards

    Luca
  • Hi Luca,

    Yes, are you able to run the out of box demo? It has a scenario involving the accelerometer.
    Are you calling I2C_IF_Open() ?

    Regards,
    Gigi Joseph.
  • Hi gigi ,

    I call this on the main :

    lRetVal = I2C_IF_Open(I2C_MASTER_MODE_FST);
    if(lRetVal < 0)
    {
    ERR_PRINT(lRetVal);
    LOOP_FOREVER();
    }


    and then

    //Init Accelerometer Sensor
    lRetVal = BMA222Open();
    if(lRetVal < 0)
    {
    ERR_PRINT(lRetVal);
    LOOP_FOREVER();
    }


    and then inside the udp client function I would like to call

    void ReadAccSensor()
    signed short ReadAccSensor()
    {
    //Define Accelerometer Threshold to Detect Movement
    const short csAccThreshold = 5;

    signed char cAccXT1,cAccYT1,cAccZT1;
    signed char cAccXT2,cAccYT2,cAccZT2;
    signed short sDelAccX, sDelAccY, sDelAccZ;
    int iRet = -1;
    int iCount = 0;

    iRet = BMA222ReadNew(&cAccXT1, &cAccYT1, &cAccZT1);
    if(iRet)
    {
    //In case of error/ No New Data return
    return;
    }
    //for(iCount=0;iCount<2;iCount++)
    for(iCount=0;iCount<1;iCount++)
    {
    MAP_UtilsDelay((90*80*1000)); //30msec
    iRet = BMA222ReadNew(&cAccXT2, &cAccYT2, &cAccZT2);
    if(iRet)
    {
    //In case of error/ No New Data continue
    iRet = 0;
    continue;
    }

    else
    {
    sDelAccX = abs((signed short)cAccXT2 - (signed short)cAccXT1);
    sDelAccY = abs((signed short)cAccYT2 - (signed short)cAccYT1);
    sDelAccZ = abs((signed short)cAccZT2 - (signed short)cAccZT1);

    //Compare with Pre defined Threshold
    if(sDelAccX > csAccThreshold || sDelAccY > csAccThreshold ||
    sDelAccZ > csAccThreshold)
    {
    //Device Movement Detected, Break and Return
    g_ucDryerRunning = 1;
    break;
    }
    else
    {
    //Device Movement Static
    g_ucDryerRunning = 0;
    }
    }
    }
    return (sDelAccX);
    }

    but I can't do the last step with the function because I can't read from the bus..

    I hope that you can help me
  • HI,

    How about the out_of_box demo? Does it work?

    Regards,
    Gigi Joseph.
  • Hi ,

    I try to load it but I can see on the terminal only if the connection is ok..
    How Can I see if the sensors are ok ??
  • Hi ,

    I tried the example application and I don't see the error for the I2C bus.. 

    But i don't understand what can be the problem for my application..

    Do you have any advices ??

    Regards

             LUca

  • Hi to everybody ,

    I am trying to use the accelerometer for a my application but i have an error ( read from I2C FAILDED)..

    I tried the out of box example application and I don't have this error.

    Why is there this error in mine ??

    I use this :

    // I2C Init
    //
    lRetVal = I2C_IF_Open(I2C_MASTER_MODE_FST);
    if(lRetVal < 0)
    {
    ERR_PRINT(lRetVal);
    LOOP_FOREVER();
    }

    //Init Temprature Sensor
    lRetVal = TMP006DrvOpen();
    if(lRetVal < 0)
    {
    ERR_PRINT(lRetVal);
    LOOP_FOREVER();
    }

    //Init Accelerometer Sensor
    lRetVal = BMA222Open();
    if(lRetVal < 0)
    {
    ERR_PRINT(lRetVal);
    LOOP_FOREVER();
    }

  • Hi to everybody ,

    I have a problem when I try to enable the accelerometer..

    I tried a lot things but I can't solve..

    Do you have some possible solutions ??

    Thanks  A lot

  • Hi Luca, please make sure you have the correct pinmux configuration. You can copy this from out of box as well.

    -Aaron
  • Hi Aaron ,

    You have solved the problem.. I didn't check the pinmux file because it had the same name and I thought the configuration was the same for each test..

    Now I can try to use the sensors..

    void ReadAccSensor()

    {

       //Define Accelerometer Threshold to Detect Movement

       const short csAccThreshold    = 5;

       signed char cAccXT1,cAccYT1,cAccZT1;

       signed char cAccXT2,cAccYT2,cAccZT2;

       signed short sDelAccX, sDelAccY, sDelAccZ;

       int iRet = -1;

       int iCount = 0;

       iRet = BMA222ReadNew(&cAccXT1, &cAccYT1, &cAccZT1);

       if(iRet)

       {

           //In case of error/ No New Data return

           return;

       }

       //for(iCount=0;iCount<2;iCount++)

       for(iCount=0;iCount<1;iCount++)

       {

           MAP_UtilsDelay((90*80*1000)); //30msec

           iRet = BMA222ReadNew(&cAccXT2, &cAccYT2, &cAccZT2);

           if(iRet)

           {

               //In case of error/ No New Data continue

               iRet = 0;

               continue;

           }

           else

           {

               sDelAccX = abs((signed short)cAccXT2 - (signed short)cAccXT1);

               sDelAccY = abs((signed short)cAccYT2 - (signed short)cAccYT1);

               sDelAccZ = abs((signed short)cAccZT2 - (signed short)cAccZT1);

               //Compare with Pre defined Threshold

               if(sDelAccX > csAccThreshold || sDelAccY > csAccThreshold ||

                  sDelAccZ > csAccThreshold)

               {

                   //Device Movement Detected, Break and Return

                   g_ucDryerRunning = 1;

                   break;

               }

               else

               {

                   //Device Movement Static

                   g_ucDryerRunning = 0;

               }

           }

       }

     return ();

     

    Can I use this function to read data from the accelerometer ?? do you think it is ok ?

    I would like to take these data and send it inside udp packets using wifi direct.. So I would like to use what I read inside the udp client function..

    What do you think ??

    THanks a lot

    BEST REGARDS

     Luca

  • You should probably change a lot of the function. They take absolute values of the acc. values, and do other stuff you probably don't want.

    -Aaron
  • Ok thanks !!

    Luca
  • Hi Aaron ,

    I tried with the temperature sensor..

    float temperatura ;
    TMP006DrvGetTemp(&temperatura);


    UART_PRINT("Temperatura %ld ", temperatura);

     


    The value on the terminal is :  544210944

    what does it mean ?? It is a strange value for the temperature 

  • I modified with

    UART_PRINT("Temperatura %.2f \n\r", temperatura);

    but the value for the temperatur is always 0,00

    why ??? :(

  • What does the entire temperature read sequence look like?

    -Aaron
  • Hi Aaron ,

    What do you mean ??

    luca
  • Please post the rest of the code
  • HI Aaron ,

    the main :

    int main()
    {
    long lRetVal = -1;

    //
    // Initialize Board configurations
    //
    BoardInit();


    //
    // Pinmuxing for GPIO, UART
    //
    PinMuxConfig();

    PinConfigSet(PIN_58,PIN_STRENGTH_2MA|PIN_STRENGTH_4MA,PIN_TYPE_STD_PD);

    // ENABLE RTC CLOCK FOR TIMESTAMP
    PRCMRTCInUseSet();

    //
    // configure LEDs
    //
    GPIO_IF_LedConfigure(LED1|LED2|LED3);

    // off all LEDs
    GPIO_IF_LedOff(MCU_ALL_LED_IND);

    #ifndef NOTERM
    //
    // Configuring UART
    //
    InitTerm();
    #endif


    //
    // Display the Application Banner
    //
    DisplayBanner(APP_NAME);

    // I2C Init
    //
    lRetVal = I2C_IF_Open(I2C_MASTER_MODE_FST);
    if(lRetVal < 0)
    {
    ERR_PRINT(lRetVal);
    LOOP_FOREVER();
    }

    //Init Temprature Sensor
    lRetVal = TMP006DrvOpen();
    if(lRetVal < 0)
    {
    ERR_PRINT(lRetVal);
    LOOP_FOREVER();
    }

    //Init Accelerometer Sensor
    lRetVal = BMA222Open();
    if(lRetVal < 0)
    {
    ERR_PRINT(lRetVal);
    LOOP_FOREVER();
    }


    UART_PRINT("Scan Wi-FI direct device in your handheld device\n\r");

    // Initializing the CC3200 device
    lRetVal = StartDeviceInP2P();
    if(lRetVal < 0)
    {
    UART_PRINT("Start Device in P2P mode failed \n\r");
    LOOP_FOREVER();
    }

    lRetVal = P2PConfiguration();
    if(lRetVal < 0)
    {
    UART_PRINT("Setting P2P configuration failed\n\r");
    LOOP_FOREVER();
    }

    /* Connect to configure P2P device */
    lRetVal = WlanConnect();

    if(lRetVal == 0)
    {
    GPIO_IF_LedOn(MCU_IP_ALLOC_IND);
    }
    else
    {
    UART_PRINT("Reset the device and try again\n\r");
    LOOP_FOREVER();
    }

    if(DisplayIP() < 0)
    {
    UART_PRINT("Get IP address failed \n\r");
    LOOP_FOREVER();
    }


    UART_PRINT("Send UDP packets from CC3200's IP\n\r");


    /*After calling this function, you can start sending data to CC3200 IP
    * address on PORT_NUM */
    if(!(IS_CONNECT_FAILED(g_ulStatus)))
    {

    if(type_mode==1)
    {
    //MAP_UtilsDelay(91250000);
    lRetVal = BsdUdpClient(PORT_NUM_UDP ); /// CLIENT UDP IF TYPE_MODE== 1 ---SEND UDP PACKETS
    }

    else if (type_mode==0)
    {

    lRetVal = BsdTcpClient(PORT_NUM_TCP ); /// CLIENT TCP IF TYPE_MODE== 0 --- SEND TCP PACKETS
    }
    if(lRetVal >= 0)
    {
    if(type_mode==1)
    {
    UART_PRINT("Sent UDP packets successfully \n\r");
    }
    else if (type_mode==0)
    {
    UART_PRINT("Sent TCP packets successfully \n\r");
    }
    }
    else if(lRetVal == CLIENT_DISCONNECTED)
    {
    UART_PRINT("P2P Client disconnected \n\r");
    }
    else
    {
    UART_PRINT("packets receive failed \n\r");
    }

    }

    if(lRetVal >=0)
    {
    UART_PRINT("Test passed, exiting application... \n\r");
    }
    else
    {
    UART_PRINT("Test failed, exiting application... \n\r");
    }

    // revert Device into STA mode and power off Network Processor

    lRetVal = sl_WlanSetMode(ROLE_STA);
    if(lRetVal < 0)
    {
    ERR_PRINT(lRetVal);
    LOOP_FOREVER();
    }

    lRetVal = sl_Stop(SL_STOP_TIMEOUT);

    GPIO_IF_LedOff(MCU_IP_ALLOC_IND);


    while(1)
    {
    _SlNonOsMainLoopTask();
    }

    }

     


    And inside the udp client function I add :

    float temperatura ;
    TMP006DrvGetTemp(&temperatura);


    UART_PRINT("Temperatura %.2f \n\r", temperatura);

  • and if I put the condition

    iRet = BMA222ReadNew(&accX, &accY, &accZ);
    if(iRet)
    {
    //In case of error/ No New Data return
    ERR_PRINT(iRet);
    }

    This for the accelerometer but it the same for the temperature sensor.. I always have iRet equals to zero.. I don't have the success for the function..
    What is the problem for you ??
    For this reason I can't have a right result
  • Hi ,

    The value for the temperature after the calling of TMP006DrvGetTemp(&temperatura) function is + Inf..

    What is the mistake ?


  • Luca,

    What is the warning for the call to TMP006DrvGetTemp?


    -Aaron

  • What do yuo mean with warning ?? i need to pass a pointer to a float for this function..
    I need to do other things ??

    Luca
  • That line is underlined in yellow...
  • Hi ,

    I can' t see this line.. Where is it ?

    Best Regards

              Luca Rossini

  • In your code, the yellow underline indicates a warning

    -Aaron

  • Hi ,
    ok I'll check.
    For the accelerometer what is the highest sampling rate ??
    I would like to acquire samples each 10 ms... it is possible ??
    I tried without a delay and application crashes.
    I need to set the sampling rate with the delay or there is another method ?

    thanks 

    Luca