cancel
Showing results for 
Search instead for 
Did you mean: 

How to get GPIO pin status ?

bd678834
Associate II
Posted on December 27, 2009 at 16:04

How to get GPIO pin status ?

4 REPLIES 4
bd678834
Associate II
Posted on May 17, 2011 at 13:35

Hello !

First of all i want to thank all who helped me to get started with STM32 :-]

Now i want to write a program that reports gpio pin MODE and gpio pin SPEED of a certain GPIOx port via rs232 to my computer.

Can some one please suggest me how do i get that GPIOx pin info ?

Can i get that info from CRL/CRH ?

How do i access to a specific port pins configuration ?

Thanks 🙂

armmcu
Associate II
Posted on May 17, 2011 at 13:35

Yes Right , you can get it from CRL/CRH registers.

Cheers.

sofiene
Associate III
Posted on May 17, 2011 at 13:35

Hi bd678834;

of course you can get the GPIO info from CRL/CRH registers since they are ''rw'' (read/write) access.

For the specific port configuration you can use the standard library or you can do it using the direct access to the registers:

GPIOC->CRL = u32_Value; // to configure port C pins

u32_Value = GPIOC->CRL; // to read the pins configuration of port C

B.R.

M3allem

tomas23
Associate II
Posted on May 17, 2011 at 13:35

Hello bd678834,

why this? The pins have their default configuration (input hi-Z, except some pins like JTAG, all described in the datasheet), and you as a programmer are responsible for changing them.

So reading CRL/CRH is good approach, but a little unnecessary (I guess) because you should already know the result 🙂