I am using a STM32f407 Dicovery board here. I try to toggle a GPIO pin as fast as possible.
palClearPad(GPIOE, 15);
//mDelay(18);
palSetPad(GPIOE, 15);
//mDelay(18);
If I toggle without delay only random spikes can be seen. When I enable the delay I can see the pin changing states on the Oszi. The same works much faster in a project without ChibiOS by using CMSIS-libraries. So it has probably to do with the clock and or port init. Has anyone had similar problems and could give me a hint which setting could be wrong ?
Thanks Michael
GPIO not working as expected
Moderator: RoccoMarco
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: GPIO not working as expected
Hi,
The STM32F4 GPIO ports have a maximum frequency setting, it depends on how fast those GPIO bits are programmed.
PAL functions are inlined inside the calling application so it is possible that the generated pulses are too fast for the GPIO to react. You may try to add few cycles in between using the halPolledDelay() (the parameter is the number of cycles).
Giovanni
The STM32F4 GPIO ports have a maximum frequency setting, it depends on how fast those GPIO bits are programmed.
PAL functions are inlined inside the calling application so it is possible that the generated pulses are too fast for the GPIO to react. You may try to add few cycles in between using the halPolledDelay() (the parameter is the number of cycles).
Giovanni
-
mr_michael_s
- Posts: 13
- Joined: Sat Jul 07, 2012 1:08 pm
Re: GPIO not working as expected
If I insert waits between the toggles it works, but its much slower compared to doing it without the ChibiOS. It must be something with the clock setup, prescalers or GPIO-config or flash-waitstate etc...
Thank You
Michael
Thank You
Michael
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: GPIO not working as expected
ChibiOS uses the optimal settings as far I know. Are your GPIOs programmed for maximum speed? if in doubt check the SPEEDR GPIO register or alternatively post your initialization code.
Giovanni
Giovanni
-
mr_michael_s
- Posts: 13
- Joined: Sat Jul 07, 2012 1:08 pm
Re: GPIO not working as expected
Ahhhhhhhhh, finally I found my mistake...
the APB1 Divider somehow was set at 16, at 4 everything is OK.
Arrrrrrrrrggghg..
Michael
the APB1 Divider somehow was set at 16, at 4 everything is OK.
Arrrrrrrrrggghg..
Michael
-
mr_michael_s
- Posts: 13
- Joined: Sat Jul 07, 2012 1:08 pm
Re: GPIO not working as expected
Well the main difference was the optimization settings for te compiler -O0 is ok but -O2 doesn't work. Some I will have a look at the generated code....
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: GPIO not working as expected
-O2 is much faster than -O0 so probably it is just adding more cycles between operations.
Giovanni
Giovanni