Okay, my last big hurdle I think of working with the STM32F4. I've looked through the documents talking about callbacks that get called from an interrupt, and the different ways you can implement them to get different behavior.
What I do not understand is how I associate a digital IO with an interrupt, if I can set some sort of priorities, and how I set what conditions of the Digital IO will fire the interrupt. I've no problem reading more in the user guide for the STM32F4, that said, the reason I ask here is I want to do it properly with how it's expected withing the ChibiOS framework.
To give even a further example of what I am doing, I have a digital encoder attached to 2 inputs. Turning the knob generates two bit grey codes and I'd like a change on EITHER channel to trigger an interrupt so that I can take action based on the current state of both ports.
Any pointers would be greatly appreciated!
Thanks,
Rick
Help working with Interrupts....
Moderator: RoccoMarco
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: Help working with Interrupts....
Hi,
What you are looking for is the EXTI unit of the STM32, this unit is supported in ChibiOS by the EXT driver, you can find an example under ./testhal/STM32F4xx/EXT. Basically it gives you callbacks on pins state changes. The driver allows to monitor up to 16 distinct pins plus several other internal sources.
Giovanni
What you are looking for is the EXTI unit of the STM32, this unit is supported in ChibiOS by the EXT driver, you can find an example under ./testhal/STM32F4xx/EXT. Basically it gives you callbacks on pins state changes. The driver allows to monitor up to 16 distinct pins plus several other internal sources.
Giovanni
-
Rick Burnett
- Posts: 150
- Joined: Tue Jan 08, 2013 2:20 pm
Re: Help working with Interrupts....
That's what I was looking for, thanks! I did read through the documentation to make sure I understood how it worked (From the STM32F4 level) but wasn't sure where to look for the ChibiOS level. Of course, looking in the driver section should have been my first instinct! Haha.
Thanks!
Rick
Thanks!
Rick
-
Rick Burnett
- Posts: 150
- Joined: Tue Jan 08, 2013 2:20 pm
Re: Help working with Interrupts....
An additional question, looking at this post:
viewtopic.php?f=2&t=455&p=4087&hilit=EXT_MODE_GPIOA#p4087
The last comment says (if I am reading it correctly) if I turn on multiple ports for an EXT line, like so:
{EXT_CH_BOTH_EDGES | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOB | EXT_MODE_GPIOD,extcb2}
That in this case, since this is EXT2, if B2 or D2 changed, it would fire the callback. I'd just have to determine in the callback which one it was by keeping the previous values around and seeing who changed.
Is this assumption correct?
Rick
viewtopic.php?f=2&t=455&p=4087&hilit=EXT_MODE_GPIOA#p4087
The last comment says (if I am reading it correctly) if I turn on multiple ports for an EXT line, like so:
{EXT_CH_BOTH_EDGES | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOB | EXT_MODE_GPIOD,extcb2}
That in this case, since this is EXT2, if B2 or D2 changed, it would fire the callback. I'd just have to determine in the callback which one it was by keeping the previous values around and seeing who changed.
Is this assumption correct?
Rick
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: Help working with Interrupts....
Careful, the EXTI only allows a certain bit to be mapped on a single port, so if you use the line EXTI 2 on GPIOB you cannot use the same line on GPIOD too, you have to use another bit number.
See the RM for details, the drivers abstract a lot but the underlying hardware cannot be ignored.
Giovanni
See the RM for details, the drivers abstract a lot but the underlying hardware cannot be ignored.
Giovanni
-
Rick Burnett
- Posts: 150
- Joined: Tue Jan 08, 2013 2:20 pm
Re: Help working with Interrupts....
Yeah, it definitely does not work. I tried mapping bit 2 of B and D to EXT2 and it did not work. I looked through all the ST documentation and I don't see anything that says the EXTI lines are or'd together. I've reworked my code to use individual EXT ports for only specific bit/channel as you are saying.