Zero compass values in I2C-LSM303DLHC example

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderators: RoccoMarco, barthess

gav-gav
Posts: 10
Joined: Fri Sep 01, 2023 7:29 am

Zero compass values in I2C-LSM303DLHC example

Postby gav-gav » Fri Sep 01, 2023 8:00 am

Hello!
I downloaded last Chibios studio , bought STM32F303 Discovery kit and wanted to check the work of LSM303DLHC accelerometr/magnitometr.
So I built chibios2111\testex\STM32\STM32F3xx\I2C-LSM303DLHC example and debug it on STM32F303 Discovery kit.

But when I had received example results using virtual com-port , I found the problem:
- raw and cooked compass data by all axes have zero values, see the example output below.

LSM303DLHC Accelerometer raw data...
X-axis: -704
Y-axis: -128
Z-axis: 7680
LSM303DLHC Compass raw data...
X-axis: 0
Y-axis: 0
Z-axis: 0
LSM303DLHC Accelerometer cooked data...
X-axis: -85.958
Y-axis: -23.443
Z-axis: 945.542
LSM303DLHC Compass cooked data...
X-axis: 0.000
Y-axis: 0.000
Z-axis: 0.000

I tried other STM32 F303 Discovery kit but problem repeated.

Can you help me?

Best Regards

Alexey Gavrilov

User avatar
RoccoMarco
Posts: 655
Joined: Wed Apr 24, 2013 4:11 pm
Location: Munich (Germany)
Has thanked: 83 times
Been thanked: 67 times
Contact:

Re: Zero compass values in I2C-LSM303DLHC example

Postby RoccoMarco » Fri Sep 01, 2023 1:37 pm

Hi Alexey,
I am not having a Discovery F3 with me right now. I will open a ticket and look into it as soon as I get my hand on the board.

What revision of F3 are you using?
Ciao,
RM

gav-gav
Posts: 10
Joined: Fri Sep 01, 2023 7:29 am

Re: Zero compass values in I2C-LSM303DLHC example

Postby gav-gav » Mon Sep 04, 2023 8:18 am

Hello!
Thank you for quick answer.
I can't read revision number on the paper sheet attached to STM32F303 Discovery Kit.
So I only red this kit features:
1) STM32F303VC MCU
-STM32F303VCT6 MCU with 72 MHz/90 DMIPS
Arm Cortex-M4 core
perfomance from Routine
Booster (CCM-SRAM)
- 256 Kbytes of Flsh Memory
2) Gyroscope +acceleration &
magnetic sensors MEMS
3)Embedded ST-SINK/V2-B with
USB interface for debugging
and programming

See attached photo.

Hope on your help
Best Regards
Alexey Gavrilov
Attachments
IMG_3913.jpg
IMG_3914.jpg

gav-gav
Posts: 10
Joined: Fri Sep 01, 2023 7:29 am

Re: Zero compass values in I2C-LSM303DLHC example

Postby gav-gav » Mon Sep 04, 2023 8:29 am

Hello!
Also when I had connected to device with the STLINK utilty, it displayed the information:
DEVICE: STM32F302xB-xC/F302xB-xC/F358xx.
May be it will be useful for you.
Best Regards
Alexey Gavrilov

gav-gav
Posts: 10
Joined: Fri Sep 01, 2023 7:29 am

Re: Zero compass values in I2C-LSM303DLHC example

Postby gav-gav » Mon Sep 04, 2023 9:20 am

Also I red in the STLink output:
Device ID: 0x422
Revision ID: Rev Y

User avatar
RoccoMarco
Posts: 655
Joined: Wed Apr 24, 2013 4:11 pm
Location: Munich (Germany)
Has thanked: 83 times
Been thanked: 67 times
Contact:

Re: Zero compass values in I2C-LSM303DLHC example

Postby RoccoMarco » Mon Sep 04, 2023 4:55 pm

Hi Alexey,
I am afraid the problem is that ST changed devices on the board. The board that you have looks pretty new to me and the documentation says:
LSM303DLHC or
LSM303AGR

I am afraid your board has the LSM303ASR and not the DLHC. Could you double-check?
Ciao,
RM

gav-gav
Posts: 10
Joined: Fri Sep 01, 2023 7:29 am

Re: Zero compass values in I2C-LSM303DLHC example

Postby gav-gav » Tue Sep 05, 2023 2:36 pm

Hi RM!
It is seemed that it is really LSM303AGR acceleration-magnetic sensors on my kit, because when I had changed address of registers from which read data from LSM30DLHC addresses to LSM303AGR addresses, some non-zero values appeared.
I will try to make my I2C-LSM303AGR example on the basis existed I2C-LSM303DLHC example.

Thank you
Alexey
P.S.
Could you check my example when it will be ready?

User avatar
RoccoMarco
Posts: 655
Joined: Wed Apr 24, 2013 4:11 pm
Location: Munich (Germany)
Has thanked: 83 times
Been thanked: 67 times
Contact:

Re: Zero compass values in I2C-LSM303DLHC example

Postby RoccoMarco » Tue Sep 05, 2023 9:07 pm

Actually if you look into the demo for stm32f4 there is a demo for that mems. The part is supported, you just have to create a custom demo.
Ciao,
RM

gav-gav
Posts: 10
Joined: Fri Sep 01, 2023 7:29 am

Re: Zero compass values in I2C-LSM303DLHC example

Postby gav-gav » Wed Sep 06, 2023 8:30 am

Hi RM!
I see that the problem exists in driver functions of devices LSM303DLHC /LSM303AGR .
Function with signature like "isLSM303DLHC()" must exist in driver of LSM303DLHC and function with signature like "isLSM303AGR ()" must exist in driver of LSM303AGR, because it is very difficult to understand which device using without these functions.
Best Regards
Alexey

User avatar
RoccoMarco
Posts: 655
Joined: Wed Apr 24, 2013 4:11 pm
Location: Munich (Germany)
Has thanked: 83 times
Been thanked: 67 times
Contact:

Re: Zero compass values in I2C-LSM303DLHC example

Postby RoccoMarco » Wed Sep 06, 2023 12:44 pm

Hi Alexey,
thanks for the feedback. I will consider adding an API in the future that checks the device ID.
Ciao,
RM


Return to “STM32 Support”

Who is online

Users browsing this forum: Bing [Bot] and 15 guests