cancel
Showing results for 
Search instead for 
Did you mean: 

GPIOC_CRL CNF2[1:0]

Gedo
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

4 REPLIES 4

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

 

No. does it matter ?

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

I fully comprehend. thanks