2017-01-04 10:52 AM
Hi everybody.
I have to implement a Wiegand reader on a STM32 demo board.Using CubeMX I have defined 2 gpios as GPIO_EXTI and now the HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) is triggered.The problem is that the callback is triggered more than the right number of times!!!The right number is 34 but the callback can be triggered 50, 40, 60 times!!!Is there a way to have a right Wiegand event?2017-01-04 12:04 PM
Suggest you differentiate and record the GPIO pin states at the events. Are the edges noisy?
2017-01-04 12:24 PM
Absolutely not.
In the origin the firmware was written using mbed. With it the wiegand implementation is perfect. The callback on falling is called exactly 34 times without eny error.The same demo board with a firmware written using CubeMX - Hal has this very strange behaviour.Is the HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
the right approach or is there another way?2017-01-04 05:43 PM
HAL_GPIO_EXTI_Callback() seems to work as expected for me. One obvious thing to check is that your edge and pull-up/pull-down settings got correctly carried over from mbed to CubeMX. Do your two /IRQ signals share the same EXTI signal or have you managed to arrange things such that they each have their own unique line? I've only got 3 /IRQ signals in my applications and my cpu variant has 3 EXTI lines (0-1, 2-3, 4-15) so I've managed to arrange things so that each is unique.
2017-01-04 08:00 PM
Just in case, if using the same interrupt for both exti, you must make sure that your code checking for the triggered pin is like this:
If then
If then
If then
If.then
And not
If then else if then else
Nor a switch case situation.
The interrupt will trigger again is one of the pending signals remains at the end of the callback.
You can also put a breakpoint to look at the exti register.
Also, if exti is configured to trigger on both edges in the hal flavours more.events will trigger.
To debug this, i would toggle 2 gpio in the callback, one for each exti source and monitor all 4 channels on a scope.
Good luck!
2017-01-05 01:20 AM
Sorry. The problem is that my personal wiegand reader is broken.