Add the following function to your main file that will enable the GPIOB port and switch the PB6 and PB9 pins to the AF4 mode (I2C):.In this example, we will use the pins PB6 and PB9 (both would need to be switched to the AF4 mode): Open the datasheet (not reference manual) for your device and locate the pins that could be used for the I2C signals. The I2C protocol uses 2 physical signals: SCL (clock) and SDA (data).Select debug settings that match your board and click “Finish” to create the project:.As we will be replacing the main() function with our own code, proceed with the default LED port settings even if they don’t match your board: Select the basic “LEDBlink” example on the next page. In this example, we will use the STM32F4-Discovery board for the I2C master, so we pick the STM32F407VG device: Proceed with the default settings (Create a new Embedded Binary using MSBuild) on the first page of the VisualGDB’s Wizard:.Enter the name and location for your project and click “Create” to launch the VisualGDB-specific part of the wizard:.Start Visual Studio and open the VisualGDB Embedded Project Wizard: We will begin with creating a basic project sending a simple message over I2C in the master mode.We will use a third STM32 board together with Analyzer2Go to look into the I2C signals.īefore you begin, install Visual Studio and VisualGDB. We will connect 2 STM32 boards using their I2C interface, will go over the I2C packet format, and will show how to use the STM32 HAL API to send and receive message using I2C. This tutorial shows how to use the I2C interface on the STM32 devices.
0 Comments
Leave a Reply. |