How to speed update time of IDR Register STM32?

OP #6080108
Lesenswert?

I have a question about the IDR Register of STM32 I set the pin0 of the 
ODR Register to 1 in my code below and i want to check, if the pin0 in 
the IDR register is set to 1. The problem is, after setting the pin to 
1, i musst wait 1 second until the pin in the IDR register is set to 1. 
How can i read the pin state without waiting. How can i handle this 
problem? ''' void init_pins(void) {

GPIOG->OTYPER |= (0x01 << 0); // Pin 0 as open drain
GPIOG->OTYPER &= ~(0x01 << 1); // Pin 1 as push - pull

GPIOG->BSRRL  =  0x01 << 1; // Pin 1 to High
GPIOG->BSRRL  =  0x01 << 0; // Pin 0 to High

microsecond_Delay(1000000);

if( !(GPIOG->IDR & 0x01) )
{
    errorCode = -1 ; //Error Code for Bus not floating
}
} '''
#6080114
Lesenswert?

The datasheet/reference manual of (for instance) STM32F10x says about 
the IDR registers: "These bits are read only and can be accessed in Word 
mode only. They contain the input value of the corresponding I/O port."

Maybe they can only be used if the pin is configured as input pin? That 
needs to be discussed.
Gast #6080429
Lesenswert?

Your problem is possibly, that the Pin needs a while to change it's 
voltage level from low to high.

You must wait a little, that is sure, but far less than a second. A 
lower Pull-Up resistor makes it faster.

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren