6702 views|37 replies

9717

Posts

24

Resources
The OP
 

STM32F103 project of LPS33HW [Copy link]

 
 

For the project written by @CCss131, stm32f103 reads lps33hw data and prints it through the serial port

Created with STM32CubeMX, based on NUCLEO-F103RB

I don't have this board, @CCss131 you try it, if you have any questions, please reply and I will fix it for you

stm32f103 lps33hw.rar (8.13 MB, downloads: 83)

This post is from MEMS sensors

Latest reply

Hello, moderator, I would like to ask if I use the STC15 series 51 microcontroller iic communication to drive this IC. Is it easy to drive? I want to try to transplant it.   Details Published on 2020-7-25 16:55
Personal signature虾扯蛋,蛋扯虾,虾扯蛋扯虾
 
 

25

Posts

0

Resources
2
 
Okay, thank you.
This post is from MEMS sensors
 
 
 

25

Posts

0

Resources
3
 
How to change to standard library to drive
This post is from MEMS sensors

Comments

Is it a standard library for stm32f103?  Details Published on 2019-9-3 19:17
 
 
 

9717

Posts

24

Resources
4
 
CCss131 posted on 2019-9-3 18:06 How can I change to the standard library to drive?
Is there a standard library for stm32f103?
This post is from MEMS sensors
 
 
 

25

Posts

0

Resources
5
 
littleshrimp posted on 2019-9-3 19:17 Is it a standard library for stm32f103?

Yes, yes, I haven't used the STM32CubeMX software yet. The board I use is STM32's C8T6. Can I modify it like this? https://bbs.eeworld.com.cn/thread-1064955-1-1.html

This post is from MEMS sensors

Comments

It is not much different from the code in this website. Just turn on i2c and uart in your project, and then put the files in the lps33hw_STdC folder into the project. Replace the corresponding functions in tx_com, platform_read, and platform_write in the read_data_simple.c file with the corresponding uart and  Details Published on 2019-9-4 15:14
 
 
 

9717

Posts

24

Resources
6
 
CCss131 posted on 2019-9-4 08:41 Yes, I haven't used the STM32CubeMX software yet. The board I use is the STM32 C8T6. Can I modify it like this? http://bbs.eeworld.c ...

It is not much different from the code in this website. Just turn on i2c and uart in your project, and then put the files in the lps33hw_STdC folder into the project.

Replace the corresponding functions in tx_com, platform_read, and platform_write in the read_data_simple.c file with the corresponding uart and i2c transceiver functions.

This post is from MEMS sensors
Personal signature虾扯蛋,蛋扯虾,虾扯蛋扯虾
 
 
 

25

Posts

0

Resources
7
 

Hello, moderator, I use SPI communication, MISO has no return value, corresponding in platform_write

u8 SPIx_Send_Byte(SPI_TypeDef* SPIx, u8 dat)
{
u8 retry = 0;
while(SPI_I2S_GetFlagStatus(SPIx, SPI_I2S_FLAG_TXE) == RESET)
{
retry++;
if(retry > 200)
return 0;
}
SPI_I2S_SendData(SPIx, data);
retry = 0;
while(SPI_I2S_GetFlagStatus(SPIx, SPI_I2S_FLAG_RXNE) == RESET)
{
retry++;
if(retry > 200)
return 0;
}
return SPI_I2S_ReceiveData(SPIx);

It is dead loop inside, what should be the problem?

This post is from MEMS sensors

Comments

Use an oscilloscope to check if the timing of CS, SCLK, and MOSI is normal. If it is normal, read who am i to see if there is any returned data.  Details Published on 2019-9-5 15:46
 
 
 

9717

Posts

24

Resources
8
 
CCss131 posted on 2019-9-5 15:05 Hello, moderator, I use SPI communication, MISO has no return value, in platform_write corresponds to u8 SPIx_Send_Byte(SPI_TypeDef* SPIx ...

Use an oscilloscope to check if the timing of CS, SCLK, and MOSI is normal.

If you read who am i normally, see if there is any data returned

This post is from MEMS sensors
Personal signature虾扯蛋,蛋扯虾,虾扯蛋扯虾
 
 
 

25

Posts

0

Resources
9
 

The waveform is like this, how should I read the address of WHO AM I?

L0}8YN_AD`FXTC0_@P_~EC7.png (27.32 KB, downloads: 0)

L0}8YN_AD`FXTC0_@P_~EC7.png
This post is from MEMS sensors

Comments

According to your timing, it should be writing CTRL_REG2 register to read who am i executing platform_read function, the register address is 0x0f  Details Published on 2019-9-5 16:14
 
 
 

9717

Posts

24

Resources
10
 
CCss131 posted on 2019-9-5 15:58 The waveform is like this, how should I read the address of WHO AM I?

According to your timing, it should be writing the CTRL_REG2 register.

Read who am i executes the platform_read function, the register address is 0x0f

This post is from MEMS sensors
Personal signature虾扯蛋,蛋扯虾,虾扯蛋扯虾
 
 
 

25

Posts

0

Resources
11
 

It cannot be read. It does not read 10110001 in WHO AN I. Is it because I configured the function incorrectly?

This post is from MEMS sensors

Comments

Let's take a look at the waveform of who am i.  Details Published on 2019-9-5 18:35
 
 
 

9717

Posts

24

Resources
12
 
CCss131 posted on 2019-9-5 18:26 It cannot be read. It does not read 10110001 in WHO AN I. Is it because the function I configured is incorrect?
Take a look at the waveform of reading who am i
This post is from MEMS sensors
 
 
 

25

Posts

0

Resources
13
 

I use the platform_read function directly in while(1) to read. Is it easier to use simulated I2C?

This post is from MEMS sensors

Comments

They are all similar. I2C is more convenient. Look at your timing of 2 wires. Are the mosi and miso marked wrong? The data sent without controlling the CS signal does not look like 0x0f  Details Published on 2019-9-6 11:39
 
 
 

9717

Posts

24

Resources
14
 
CCss131 posted on 2019-9-6 09:37 I use the platform_read function directly in while (1) to read. Is it easier to use simulated I2C?

They are almost the same, i2c is more convenient, 2 wires

Looking at your timings, are the mosi and miso marked incorrectly?

No control CS signal

The data sent does not look like 0x0f

This post is from MEMS sensors
Personal signature虾扯蛋,蛋扯虾,虾扯蛋扯虾
 
 
 

25

Posts

0

Resources
15
 

I wonder if the moderator has a similar example using the STM32F103 driver?

This post is from MEMS sensors

Comments

Please send me the test project and hardware connection and I will show it to you.  Details Published on 2019-9-6 16:38
 
 
 

9717

Posts

24

Resources
16
 
CCss131 posted on 2019-9-6 16:25 I don't know, does the moderator have a similar routine using the STM32F103 driver?
Please send the test project and hardware connection and I will show it to you.
This post is from MEMS sensors
 
 
 

25

Posts

0

Resources
17
 

Moderator, please help me take a look

stm32f103 LPS33HW.rar

8.67 MB, 阅读权限: 5, downloads: 5

This post is from MEMS sensors

Comments

" SPI: PB4-PB7 pins are used, now IIC connection is used: PB6 and PB7. I would like to ask how to change P1619 tx_com in lps_reg.c, so that data can be printed on the serial port. How to write Mian function to read and print data continuously? https://wenku.baidu  Details Published on 2019-9-7 09:26
 
 
 

9717

Posts

24

Resources
18
 
CCss131 posted on 2019-9-6 19:14 Moderator, please help me take a look

"

SPI: used PB4-PB7 pins, now use IIC connection: PB6 and PB7

I would like to ask how to change P1619 tx_com in lps_reg.c so that I can print data on the serial port

How to write a mnemonic function to read and print data continuously? https://wenku.baidu.com/view/8412fbc0dd88d0d232d46a48.html F103C8T6 pin I really hope to get your guidance, thank you!

"

This is the project I sent you at first. The original I2C connection was PB89 and PB9, but now it has been changed to PB6 and PB7.

Try this project again. If you want to print via UART, PA2 is the TX of the microcontroller, and PA3 is the RX of the microcontroller. Just connect these two wires to the corresponding serial port.

stm32f103 lps33hw.rar (8.13 MB, downloads: 18)

This post is from MEMS sensors
Personal signature虾扯蛋,蛋扯虾,虾扯蛋扯虾
 
 
 

869

Posts

0

Resources
19
 
How to change to standard library to drive
This post is from MEMS sensors
 
 
 

25

Posts

0

Resources
20
 

Hello, moderator, what is the use of the INT_DRDY pin? How to configure it? Is it used for ADC sampling? Also, I am using the hardware SPI to drive LPS33HW, and the program is stuck here. How should I solve it?

whoamI = 0;
lps33hw_device_id_get(&dev_ctx, &whoamI);

if (whoamI != LPS33HW_ID )
while(1)

This post is from MEMS sensors

Comments

INT_DRDY is a digital output pin, connected to the data input of the microcontroller. The level of this pin will change when an interrupt occurs or the data is ready. The SPI is stuck there because the read who am i does not correspond to the device. In most cases, it is because of communication errors and no data is read.  Details Published on 2019-9-9 15:10
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

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