cancel
Showing results for 
Search instead for 
Did you mean: 

I2C sensor on USART 2 Serial communication

sanathhere
Associate III

Hello, 

I am using the embedded coder support package in simulink to interface with my onboard MEMS acceleration sensor (LSM303AGR) on my STM32F411VET discovery board. I could successfully connect and run simple LED program through USART2 on simulink block and it returns button state values as well on display, while running in external mode.

I am moving on to more complicated communication, where i am accessing the I2C sensor via USART2 but I am not able to establish a communication. I have I2C read and I2C write blocks inside the embedded coder package which i am using along with correct read and write addresses for the sensor. 

However, My I2C sensor will not respond over USART2, is there a step which I am missing? 

How does one transmit and receive I2C sensor data over USART2 serial communication?

Your help would be appreciated.

 

3 REPLIES 3
Issamos
Lead II

Hello @sanathhere 

This link shows exactly how to do this.

Best regards.

II

Hello, Thank you for the response, I did infact you this same example to configure my sensor however, on the board I am still only connected to USART2 Tx and Rx, would it be able to call my I2C data directly, my system code compiles fine, it is the external mode serial communication which causes issues and wont detect my board.

The link gives a full description. I think if you compare it to your configurations, you will find the source of issue.

Best regards.

II