GPIOC_CRL CNF2[1:0]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-08-02 1:11 AM - edited ‎2023-08-02 1: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.
- Labels:
-
STM32F1 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-08-02 2: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-08-02 1: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-08-02 1:33 AM - edited ‎2023-08-02 1:40 AM
No. does it matter ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-08-02 2: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-08-02 11:12 PM
I fully comprehend. thanks
