Skip to main content
Associate
June 1, 2024
Question

BMA456 STM32

  • June 1, 2024
  • 5 replies
  • 2156 views

Hi, I have a project to finish where I have to use a bma456, which is a step counter sensor, on stm32CubeIde. But I can't seem to be able to do it, by running my own code or by using the code given on the git, I always seem to be stuck on the burst and the use of the initialisation file. The site is https://wiki.seeedstudio.com/Grove-Step_Counter-BMA456/

if anyone has already did a project on this type of sensor please help me, the deadline is coming at a rapid pace.

I have all the basic functions on STM32CubeIDE but everytime I implement something to work on this sensor, I end up stuck.

I just need to retrieve data, that's all

Please help me

    This topic has been closed for replies.

    5 replies

    Tesla DeLorean
    Guru
    June 1, 2024

    >>.. the deadline is coming at a rapid pace.

    Monday?  https://www.fiverr.com/

    Connected to What?

    Connected How?

    Show what you've coded so far.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    padawan
    Senior
    June 4, 2024

    Ok

    you know that you have to shift the adress? So you have to ask at adress 0x30 or 0x32.

     

     

    /*
    Test I2c Adress
    in : Adress to test
    return 1= found 0= notfound
    */
    uint8_t i2c_found(uint8_t i2cAddr)
    {
    HAL_StatusTypeDef _hal;
    I2C_HandleTypeDef* _i2c = &hi2c1;
    
    _hal=HAL_I2C_IsDeviceReady(_i2c,i2cAddr,2,1000);
    
    return (_hal==HAL_OK);
    }

     

     

    Insert at I2C_HandleTypeDef* _i2c = &hi2c1; your i2c port

    Do you get a "1" ?

    So you are sure your sensor is talking to you.

    hth

    padawan

     

    dawlonAuthor
    Associate
    June 4, 2024

    So I have the code of the github, except that I replace the class by struct and the arduino code used to send data by a Hal_I2c_Write.

    The problem that I stumble upon is I need to send an enormous amount of data ~ 1700 on a register 0x5E, 0X5C and 0X5B. The problem is that I'm stuck in the "for" that is sending the data. I never get to the line 793

    dawlon_0-1717506916917.png

    dawlon_1-1717506938260.png

    Tesla DeLorean
    Guru
    June 4, 2024

    Link to the GitHub repo that you're talking about, show your code additions..

    This One?

    https://github.com/Seeed-Studio/Seeed_BMA456/blob/master/arduino_bma456.cpp

    How does it handle failure? ie not seeing NACK for slave access. You have to fail 1700 times? Or fail once to know it's not working?

    ST expects the Slave address to be in the top 7-bits, usually requiring (slaveaddr << 1) vs Arduino

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    padawan
    Senior
    June 4, 2024

    In the "bma4_defs 

    you have to set 

    /**\name I2C slave address */
    #define	BMA4_I2C_ADDR_PRIMARY	UINT8_C(0x18)
    #define	BMA4_I2C_ADDR_SECONDARY	UINT8_C(0x19)
    #define BMA4_I2C_BMM150_ADDR UINT8_C(0x10)
    
    to
    /**\name I2C slave address */
    #define	BMA4_I2C_ADDR_PRIMARY	UINT8_C(0x30)
    #define	BMA4_I2C_ADDR_SECONDARY	UINT8_C(0x32)
    #define BMA4_I2C_BMM150_ADDR UINT8_C(0x20)

     

    Note arduino != STM HAL

    hth

    padawan