Jump to content

Motorcycle dynamics monitor


marcaz

Recommended Posts

Hi,

Short intro:

Base - STM32F746G-Discovery

MEMS - BMP085 Baro sensor, BMA180 Accelerometer, ITG3205 Gyro

Purpose is to monitor and display motorcycle lean angles and braking, accelaration. In future contact less IR temperature sensor (TMP007 propably) will be integrated to measure tire temperature. Here is short video and a problem I would like to discuss.

Problem: during I2C read routine display is flickering and gets distorted. Seems like uGFX task does not get processing time. I2C reading is done every 10 miliseconds via interrupts. maybe some thoughts?

 

Also giving access to this repo:

https://marcaz@bitbucket.org/marcaz/motomoni_cm7.git

p.s. seems like that make impact to that flockering

while (HAL_I2C_GetState(i2c_handler) != HAL_I2C_STATE_READY)

Read and write routines:

HAL_StatusTypeDef I2Cx_ReadMultiple(I2C_HandleTypeDef *i2c_handler,
                                           uint8_t Addr,
                                           uint8_t Reg,
                                           uint8_t *Buffer,
                                           uint16_t Length)
{
    uint32_t err_cnt = 0;
    uint32_t rd_cnt = 0;
    HAL_StatusTypeDef status = HAL_OK;
    uint32_t err;
    
    while( HAL_I2C_Mem_Read_IT(i2c_handler,(uint16_t)Addr, Reg, I2C_MEMADD_SIZE_8BIT,Buffer, Length)!= HAL_OK){
        err_cnt++;
//        osDelay(10);
    }

    while (HAL_I2C_GetState(i2c_handler) != HAL_I2C_STATE_READY)
    {
        rd_cnt++;
        osDelay(1);
    } 

    if( err_cnt > 2 || rd_cnt > 2){
        db("[RD] er:%u, rd:%u\r\n",err_cnt,rd_cnt);
    }
    /* Return OK */
    return HAL_OK;
   
}

HAL_StatusTypeDef I2Cx_WriteMultiple(I2C_HandleTypeDef *i2c_handler,
                                            uint8_t Addr,
                                            uint8_t Reg,
                                            uint8_t *Buffer,
                                            uint16_t Length)
{
    uint32_t err_cnt = 0;
    uint32_t rd_cnt = 0;
    HAL_StatusTypeDef status = HAL_OK;
    uint32_t err;
    uint8_t d[2];
    
    d[0] = Reg;
    d[1] = *Buffer; 
    
  
    while (HAL_I2C_Mem_Write_IT(i2c_handler, Addr, Reg, Reg > 0xFF ? I2C_MEMADD_SIZE_16BIT : I2C_MEMADD_SIZE_8BIT, Buffer, Length) != HAL_OK) {
     /* Check error */
        err = HAL_I2C_GetError(i2c_handler); 
        if (err != HAL_I2C_ERROR_NONE) {
                db("erroras i2c a:%X\r\n",err);
                break;
        }
        err_cnt++;

    }

    while (HAL_I2C_GetState(i2c_handler) != HAL_I2C_STATE_READY)
    {
        rd_cnt++;
        osDelay(1);    
    }
      
    if( err_cnt > 2 || rd_cnt > 2){
        db("er:%u, rd:%u\r\n",err_cnt,rd_cnt);
    }
    return status;
}

 

VIDEO0075.mp4

Edited by marcaz
Link to comment
Share on other sites

It looks like the memory (framebuffer) access gets disrupted. Is it possible that you're writing to the display from multiple threads without having GDISP_NEED_MULTITHREAD set to TRUE in your configuration file?

Other than that, is it possible that your I2C pins are shared with the FMC pins? It really seems like the panel synchronization signals are getting screwed up.

Link to comment
Share on other sites

1 hour ago, Joel Bodenmann said:

It looks like the memory (framebuffer) access gets disrupted. Is it possible that you're writing to the display from multiple threads without having GDISP_NEED_MULTITHREAD set to TRUE in your configuration file?

Other than that, is it possible that your I2C pins are shared with the FMC pins? It really seems like the panel synchronization signals are getting screwed up.

Thanks for ideas. Will check after work and give feedback ;)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...