5239 views|11 replies

9707

Posts

24

Resources
The OP
 

[NUCLEO-L4R5ZI transplantation LSM6DSL driver] 1. Communication verification [Copy link]

 
 This post was last edited by littleshrimp on 2018-6-24 20:14
LSM6DSL supports SPI and I2C communication. The evaluation board uses the I2C interface. The pin order is SCL, SDA, VDD, INT1, INT2
It is just connected to the I2C of Arduion. It is necessary to lead a 3.3V from PIN7 of CN8 to PIN6 of CN7.
The official website can be used for the LSM6DSL drivers en.x-cube-mems1, en.x-cube-mems-xt1_firmware and C-Driver-MEMS on STM32
But none of them support the NUCLEO-STM32LR45ZI board
Directly changing it in the original project requires retaining the original file structure, which is not very convenient to use.
Or using STM32CubeMX to generate a new project, and then transplant the LSM6DSL related parts.
No matter which method is used, according to past experience, it is not an easy task.
The project generated by STM32CubeMX is more flexible and convenient for future modification. Finally, I decided to use this method.
First create a new project in STM32CubeMX and select the NUCLEO-L4R5ZI board.
Find I2C1 and select I2C in the list below
Set the functions of PB8 and PB9 to I2C1_SCL and I2C1_SDA
The functions of PA5 and PA6 are set to GPIO_EXTx to receive the interrupt of LSM6DSL
The clock is changed to MSI, 120M (HSE is selected by default, and HSE does not have an external crystal oscillator)
Change the aliases of PA5 and PA6 pins to LSM6DSL_INTx
Tick EXIT LINE[9:5] interrupts
Set UART parameters
Click Generate Code to generate the project and open the project with the corresponding IDE. At this step, most of the work of MCU setting has been completed.
0)]In order to verify whether the configuration is correct and the hardware is normal, you can add the following code to USER CODE BEGIN 2
0x0f is the address of who_am_i
0xd4 is the device ID of LSM6DSL (when SAD is LOW)
/* USER CODE BEGIN 2 */
[align= left] //Read who am i
static uint8_t who_am_i;[/ font]
HAL_I2C_Mem_Read(&hi2c1,0xd4,0x0f,I2C_MEMADD_SIZE_8BIT,&who_am_i,1,0x100);
[color=rgb(0, 0, 0) ] HAL_UART_Transmit(&hlpuart1,&who_am_i,1,500);
/* USER CODE END 2 */
Open the serial port assistant. If the received data is 6A, it means that the microcontroller and LSM6DSL communicate successfully.
0)]
This post is from MEMS sensors

Latest reply

Thanks, I have something new to learn.  Details Published on 2019-5-18 17:44
Personal signature虾扯蛋,蛋扯虾,虾扯蛋扯虾
 
 

1903

Posts

0

Resources
2
 
Passing by and saw
This post is from MEMS sensors
 
 
 

875

Posts

1

Resources
3
 
Is there any configuration information for LSM6DSL? I want to see if there is something wrong with my configuration. After adding low-pass filtering, the noise on the Z axis becomes larger.
This post is from MEMS sensors

Comments

Did you draw the board yourself? Try this https://en.eeworld.com/bbs/thread-649230-1-1.html  Details Published on 2018-7-3 15:54
 
 
 

9707

Posts

24

Resources
4
 
Cao Wei 1993 posted on 2018-7-3 13:14 Is there any configuration information for LSM6DSL? I want to see if my configuration is wrong. After adding low-pass filtering, the noise of the Z axis becomes larger.
Did you draw the board yourself? Try this https://en.eeworld.com/bbs/thread-649230-1-1.html
This post is from MEMS sensors
Personal signature虾扯蛋,蛋扯虾,虾扯蛋扯虾
 
 
 

9

Posts

1

Resources
5
 
Does cubemx need to install anything when writing lsm6dsl program?
This post is from MEMS sensors

Comments

If cubemx can generate the corresponding MCU project, you can directly add the corresponding I2C or SPI code in the source code, and operate the LSM6DSL register to read and write, without installing anything. This kind of code is relatively troublesome to write. If you want to be simple, you can download the LSM6DSL driver from the ST official website.  Details Published on 2018-11-5 17:27
 
 
 

9707

Posts

24

Resources
6
 
zfw152666 Published on 2018-11-5 15:20 Do I need to install anything when writing lsm6dsl program in cubemx?
If cubemx can generate the corresponding MCU project, you can directly add the corresponding I2C or SPI code in the source code, and operate the LSM6DSL register to read and write, without installing anything. This kind of code is relatively troublesome to write. If you want to keep it simple, you can download the LSM6DSL driver from the ST official website, which has all the LSM6DSL register operations written, and you can directly call the corresponding function
This post is from MEMS sensors
Personal signature虾扯蛋,蛋扯虾,虾扯蛋扯虾
 
 
 

9

Posts

1

Resources
7
 
littleshrimp posted on 2018-11-5 17:27 If cubemx can generate the corresponding MCU project, you can directly add the corresponding I2C or SPI code in the source code, and operate the LSM6DSL register to read...
Can you leave your contact information? I am not very good at debugging this module. I am using the program on the ST official website. Now the program can run, but I still don’t understand many places. I hope you can help me. QQ1812669090 15752819024 WeChatz1812669090
This post is from MEMS sensors
 
 
 

3

Posts

0

Resources
8
 
Thank you, learning, thank you OP
This post is from MEMS sensors
 
 
 

31

Posts

0

Resources
9
 
Blogger, isn't 0xd4 the address add bit of LSM6DSL? Shouldn't it be 0xd5?
This post is from MEMS sensors

Comments

The i2c function of stm32 will automatically handle the read and write bits. The write function is d4 and the read function is d5. When reading, if it is d4, it will automatically set the last bit to 1  Details Published on 2019-4-26 15:09
 
 
 

9707

Posts

24

Resources
10
 
duguyining published on 2019-4-26 14:46 Blogger, isn't 0xd4 the address plus write bit of LSM6DSL? Shouldn't it be 0xd5?
The i2c function of stm32 will automatically handle the read and write bits. The write function is d4 and the read function is d5. When reading, if it is d4, it will automatically set the last bit to 1
This post is from MEMS sensors
 
 
 

31

Posts

0

Resources
11
 
I understand, but I did a simple test and the serial port did not print any data
This post is from MEMS sensors
 
 
 

1

Posts

0

Resources
12
 
Thanks, I have something new to learn.
This post is from MEMS sensors
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list