2024-04-25 11:53 PM - last edited on 2024-04-26 12:11 AM by Peter BENSCH
Hi there !
I start a project with STM32G031k8. This board i'm gonna make is a RS485 slave on the pin 4-5-6-7 of GPIOA i put a dipswitch with pullup resistor , and i read in this way:
uint16_t Add = ( 0x00F0 & GPIOA->IDR)>> 4 ;
right now my add is 5. My problem is sometime i don't read 5 but 1 , and if i don't turn off the power and turn on again i'm still to read 1 .
I hope some one can help me to understand where i make my mistake
Thank you
Sergio
2024-04-26 02:14 AM
Carefully check your setup. Read voltage on PA4-7 with a meter. If the voltages are as expected, post what you read from GPIOA with a debugger like "p /x *GPIOA". If the meter disagrees with your expectation, carefully check your code that PA5-7 are not used by any other code. Again, interpreting "p /x *GPIOA" against the reference manual can help.
2024-04-26 02:21 AM
i did and the voltage is right . The strange thingh is afther a while i use a debug for try my function happend and is really soo strange. For sure this pin are not use for did nothingh else and i made one mistake the resistor are not pul up but pull down. I try to check the manual and see if i made somo mistake .
Thank you