Strange behavior on open-drain output mode for blue pill (STM32F103C8T6)
Guys, I need to put 5V on a pin. For this, I configured my pin as an open-drain output with a pull-up resistor (10k) between the pin and the 5V line. I checked the 5V-tolerant pins in the Blue Pill datasheet and tested many of them, but the conclusion is always the same: the output is 3.7V when the pin is in high impedance. I used Keil uVision to write my code in C (at startup, I only used CMSIS and DEVICE for pre-configuration). My code is below. I used PB10 as a reference.
#include "stm32f10x.h"
int main(){
RCC->APB2ENR |= (1 << 3); // Clock for GPIOB
// Open-drain output and HIGH impedance PB10
GPIOB->CRH &= ~(0b1111 << 8); // Cleaning bits
GPIOB->CRH |= (0b0111 << 8); // Setting up bits
GPIOB->ODR |= (1 << 10); // HIGH impedance
};Edited to apply source code formatting - please see How to insert source code for future reference.
