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.

RTOS/TM4C1294NCPDT: After power on with switch some sensor readings fail, after reset pin down everything works fine

Part Number: TM4C1294NCPDT

Tool/software: TI-RTOS

Hi everyone

I'm experimenting with a project boar which uses TI-RTOS on it and 4 sensors (each has accelerometer and gyroscope in one sensor) connected via cable.

I'm initializing everything but some times when I switch the board on and of I cant get data from one or two of the gyro sensors also the accelerometers work fine without any problem in the readings , when I'm programming the board with jtagic and try to debug it everything works fine,also when I'm resetting the board with the reset pin to ground than also everything works fine no bad sensor readings.

I also tried to delay the initialization process in the main menu,

tried a for circle to re initialise everything 2 times,

doing a HWREG(NVIC_APINT) = NVIC_APINT_VECTKEY | NVIC_APINT_SYSRESETREQ; which give me reset looping

I have no clue what can cause this problem with thew sensors.

Im using the :

RTOS version 2.16.0.08

TivaWare version 2.1.1.71b

  • The sensor that is used is KXG03
  • Hi Robert,
    Are you using the I2C or the SPI interface from the KXG03 sensor? I will suggest you use the scope or LA to observe either the I2C or SPI interface and find out whether during power up the MCU is not sending the command correctly or the sensor is not replying the data correctly.
  • Hello.

    Dyes the projekt with TIVA C tm4c1294ncpdt using (TI-RTOS)  and four KXG03 senors are  using SPI communication. Sometimes I can read all four sensors and sometime I have problems to read one of the gyro data out of four gyros and have no problems to read accelero sensors.
    I'm using the following code to read all four  sensores the code is only a guid for usage :
    configure the 4 kxg03 sensores
    if not awailable (cheking trought who_am_i register)
    than seting a flag and dont read sensors
    //this is for each 4 sensore after another
    if (sensore1 awailable ){
    isread=0
    for (i to 80){
    read status1 and int1_src1
    if (gyro_run && int_drdy_acc && int_drdy_gyro){
    read data from kxg03(into the buffer)
    real_data = add together gyro y (msb lsb) and gyro z(masb lsb)(buffer[0]+buffer[1]+buffer[2]+buffer[3]) //this way we can chack if the data is zero
    check_data= (check_data*9.997)+(real_data*0.003) filtering for better zero checking
    isread = 1
    goto cont;
    }
    }
    cont:
    if(!isread){
    sensore1_status_set = 1;
    check_data = 0;
    }
    else{
    sensore1_status_set = 0;
    }
    }
    I use this four times  after another with each sensore set to his own buffer place.
    After this I see if the sensore data is good. 
    // after the four sensor reading we do thes to resett the TIVA C
    // if there is some problem in the readings or the sensor is not connected
    if(check_data == 0){
    memset((real_datac and check_data),0 ,4 )
    restart the TIVA C with software resett 
    }
    when the sensor gets the gyro zero problem I cant use my code to check the the data for zeros and its not restarting the MCU
    Thanks for help and sorry for the bad grammar, I will wait for reply !!!
    Robert
  • Hi Robert,
    Did you have a chance to monitor the SPI interface on the scope or logic analyzer?
    Some questions/suggestions here:
    - Since you said the accelerometer always works but the gyro works most of the time, can you reverse the reading from your sensor? Read the gyro first then the accelerometer? Does it make a difference?
    - You have 4 sensors. Which sensor is giving the wrong gyro value? Is it always from the same sensor? If you change the order of reading from the 4 sensors will the same sensor as before gives the wrong data or it is now a different sensor. This will isolate if it is a specific sensor issue.
    - How did you control the chip select signals to 4 sensors? Did you manually control the CS using GPIO or the hardware SPI CS? Is there any time where two chip selects are active at the same time?
    - If you change your SPI clock frequency, will it make a difference?

    Again, it will be easier for you to debug the problem if you have the scope or LA.