2023-08-02 01:11 AM - edited 2023-08-02 01:39 AM
STM32F103RB
Hi. I tried to learn register level programming and got a problem with Port configuration register.
hire is my codes:
#include "stm32f1xx_hal.h"
int main(void){
RCC->APB2ENR |= RCC_APB2ENR_IOPCEN;
GPIOC->CRL=0;
GPIOC->CRL = GPIO_CRL_MODE2 | GPIO_CRL_MODE3;
//GPIOC->CRL |= GPIO_CRL_CNF2_0 | GPIO_CRL_CNF3_0;
//when I set other then 00 it not generating pulses. I want to set it output Open-drain.
while (1){
GPIOC->BSRR|=GPIO_PIN_2<<16;
GPIOC->BSRR|=GPIO_PIN_2;
GPIOC->BSRR|=GPIO_PIN_3<<16;
GPIOC->BSRR|=GPIO_PIN_3;
}
}
Solved! Go to Solution.
2023-08-02 02:26 AM
Push-pull output means, that when you output 0, a transistor switches output to ground, when you output 1, another transistor switches output to VDD.
Open drain output means, that when you output 0, a transistor switches output to ground, but when you output 1, nothing is swithed on and the output is left floating. If you don't have an external pullup, there's nothing which would pull the output to high.
JW
2023-08-02 01:18 AM
Please don't use other than black color for text. It's hard to read when colored.
//when I set other then 00 it not generating pulses. I want to set it output Open-drain.
Do you have external pullups connected?
JW
2023-08-02 01:33 AM - edited 2023-08-02 01:40 AM
No. does it matter ?
2023-08-02 02:26 AM
Push-pull output means, that when you output 0, a transistor switches output to ground, when you output 1, another transistor switches output to VDD.
Open drain output means, that when you output 0, a transistor switches output to ground, but when you output 1, nothing is swithed on and the output is left floating. If you don't have an external pullup, there's nothing which would pull the output to high.
JW
2023-08-02 11:12 PM
I fully comprehend. thanks