Skip to main content
Gedo
Associate II
August 2, 2023
Solved

GPIOC_CRL CNF2[1:0]

  • August 2, 2023
  • 2 replies
  • 2496 views

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;

}

}

image.png

This topic has been closed for replies.
Best answer by waclawek.jan

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

2 replies

waclawek.jan
Super User
August 2, 2023

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

 

Gedo
GedoAuthor
Associate II
August 2, 2023

No. does it matter ?

waclawek.jan
waclawek.janBest answer
Super User
August 2, 2023

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

Gedo
GedoAuthor
Associate II
August 3, 2023

I fully comprehend. thanks