I2C Scanner
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-07-24 10:53 AM
I want an I2C Scanner program for STM32F103C8T6 Blue Pill board. i will use external pullup for the i2c clock and data, because the voltage of the devices i am going to scan is 1.8V. The software should find the address of all the devices connected in the bus and return the address to the pc through UART port. default three i2c ports are not true open drain so i need alternate solution.
- Labels:
-
STM32F1 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-07-24 12:27 PM
> default three i2c ports are not true open drain so i need alternate solution.
Why do you think that?
Pins can certainly be configured in open drain mode, as referenced many times in the RM.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-07-24 9:30 PM
If you power your cpu with 1.8v, this looks OK, else you may need level shifter to detect 1.8v signals.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-07-24 10:58 PM
/* USER CODE BEGIN MX_GPIO_Init_2 */
/* Configure I2C GPIO pins: PB6 (I2C1_SCL) and PB7 (I2C1_SDA) */
GPIO_InitStruct.Pin = GPIO_PIN_6 | GPIO_PIN_7;
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; // Open-drain mode
GPIO_InitStruct.Pull = GPIO_NOPULL; // Use pull-up resistors
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; // High speed
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/* USER CODE END MX_GPIO_Init_2 */
I modified the pin as open drain, i used logic analyzer to measure the siganal but it is automatically pulled up.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-07-25 5:49 AM
I don't understand why this is an issue. SDA/SCL should be idle high.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-07-25 5:55 AM
@ctanto333 wrote:
I modified the pin as open drain
You shouldn't need to do that - it should be automatically handled by CubeMX when you enable I2C
@ctanto333 wrote:
I used logic analyzer to measure the signal but it is automatically pulled up.
Yes, having pullups is a fundamental requirement of I2C - the lines must be pulled up!
@ctanto333 wrote:Blue Pill board
The chances of this having a genuine STM32 are vanishingly small ...
A complex system designed from scratch never works and cannot be patched up to make it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-07-25 8:05 AM
I think this will be helpful with some adjustments.
https://github.com/ScarsFun/STM32_I2C_Scanner
It is designed for the STM32F103C8T6 board and scans I2C devices, outputting the addresses via USB CDC. To use external pull-ups at 1.8V, you will need to ensure proper hardware configuration, but the software provided in this repository should give you a good starting point. If you ever think of making your own version of Blue Pill, you can see this design: https://www.pcbway.com/project/shareproject/Blue_Dev_Board_Giving_the_STM32_Blue_Pill_a_facelift_223b77e5.html
