Jump to content
marcaz

Motorcycle dynamics monitor

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

Share this post


Link to post
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.

Share this post


Link to post
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 ;)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...