PAL : GPIO output default state is high? Topic is solved

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
Post Reply
Ilfirin
Posts: 6
Joined: Mon Jun 20, 2016 1:41 pm
Has thanked: 2 times

PAL : GPIO output default state is high?

Post by Ilfirin »

Hello,

I have strange behaviour on STM32F072 MCU, when setting pin to push/pull output.
I was expecting logical Low as default state (and according reference manual and StdPeriph sample it should be), but pins have high state.

It is intended, it's a bug, or bad code?

Sample code:

Code: Select all

palSetPadMode(LED_GREEN_PORT, LED_GREEN_PIN,
              PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_LOWEST);
palSetPadMode(LED_RED_PORT, LED_RED_PIN,
              PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_LOWEST);
palSetPadMode(INT_TEST_PORT, INT_TEST_PIN,
              PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_LOWEST);
palSetPadMode(INT_1_PORT, INT_1_PIN,
              PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_LOWEST);


Thank you
User avatar
RoccoMarco
Posts: 655
Joined: Wed Apr 24, 2013 4:11 pm
Has thanked: 83 times
Been thanked: 67 times

Re: PAL : GPIO output default state is high?

Post by RoccoMarco »

Hi,
default state is set in board.h (you can change this state through palSetXXX, palClearXXX or palWriteXXX).
BY the way, if you have to change pad mode in certain point of you application palSetPadMode() is the right API. If you have to set up the whole board just once (like a kind of initialization) it is highly recommended to create your own board file.
Ciao,
RM

Edit: Note that there are some tools to create your own board file.
https://www.youtube.com/watch?v=HwJqZfITvV0
Ilfirin
Posts: 6
Joined: Mon Jun 20, 2016 1:41 pm
Has thanked: 2 times

Re: PAL : GPIO output default state is high?

Post by Ilfirin »

RoccoMarco wrote:Hi,
default state is set in board.h (you can change this state through palSetXXX, palClearXXX or palWriteXXX).
BY the way, if you have to change pad mode in certain point of you application palSetPadMode() is the right API. If you have to set up the whole board just once (like a kind of initialization) it is highly recommended to create your own board file.
Ciao,
RM

Edit: Note that there are some tools to create your own board file.


And you are right.
It was there (PIN_ODR_HIGH). I know there was this default state definiton, but (wrongly) assumed, that is only about setting input/output state, not complete register, including latches.
Well, it is really better to create own board configuration, which I wanted to skip. I will learn that.

Thank you very much for your help

Edit: No I can't find out, how to mark this thread as solved. It should be at some "checklist" button, but I cannot find it.
User avatar
RoccoMarco
Posts: 655
Joined: Wed Apr 24, 2013 4:11 pm
Has thanked: 83 times
Been thanked: 67 times

Re: PAL : GPIO output default state is high?

Post by RoccoMarco »

It is the "✓" button. By the way, marked as solved.
Ciao,
RM
Post Reply