Clear Filters
Clear Filters

I2C Peripheral address and Peripheral Register address for embedded coder sensor fusion

3 views (last 30 days)
Hello, As part of my master thesis, I am working on STM32F411 Discovery board which has an onboard LSM303AGR sensor for MEMS.
My aim is to use this sensor inputs and make a mathematical model in simulink. For this purpose, I want to interface the sensor via serial communication to get continous data input from the onboard accelerometer. The embedded coder has I2C read and write blocks, and I am using this example for sensor fusion:
I am trying to replace the blocks inside this model with my target hardware I2C read and I2C write block however, I do not understand the terminology used in simulink blocks.
I have found the I2C address and I2C register address from the sensor data sheet but which address belong to which simulink block address, I am not sure. below are the addresses from datasheet
There are not many examples from where I can understand. I also looked over the block description but it does not explain much exactly what address is being referred to. Has anyone worked with I2C sensor fusion in simulink and came across this or know in general which address is which?

Accepted Answer

Raghavendra Kandur
Raghavendra Kandur on 7 Sep 2023
The "SAD" column of first table corresponds to "Peripheral address" used in I2C block.
The "Register address" column of second table corresponds to "Peripheral register address" used in I2C block.
  2 Comments
Sanath
Sanath on 12 Sep 2023
Hello, thank you so much, just on a related question, I am following this example to interface this LSM303AGR sensor in simulink. The example sensor is ADXL345, for which the very first step is '0x08' to be written to the POWER_CTL Register located at address 0x2D of the ADXL345 sensor which is to power up the sensor. My LSM303AGR sensor does not have any such power control register, how do i power up the sensor? the datasheet doesnt really state anything about the sequence of operation, it only states the general sequence of an I2C operation. Could you please help regarding the same?
Nevertheless thank you so much for your help.
Vikky Patil
Vikky Patil on 21 Sep 2023
You need to configure the Data rate in CTRL_REG1_A as part of Initialize Function. Else the sensor will be always in Power-down mode

Sign in to comment.

More Answers (0)

Products


Release

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!