Hi
Quite new to this micro python board and like it quite a bit. I was wonder if someone could shed some light on my issue.
I have a group of hall sensors that I have on a motor and need to get their value each time one of them is triggered by interrupt. If the pin itself is an interrupt I can tell which pin triggered the interrupt for that pin but not as a group value. Is it possible to set the interrupt on a port level and then read their values rather than a pin level.
For example, I use pin X1, X2, X3 and they are all on port 1. What I am trying to do is if port 1 detects an interrupt then I read all the pin values for X1, X2 and X3.
Thanks
Port groups and interrupts
Re: Port groups and interrupts
The stm32f4 processors don't have a notion of "port changed".
It only has a restricted sense of pin changed. You can watch for a particular pin changing, but you can only watch a single pin 0, and a single pin 1.
So you can watch D0 and C2, but you can't watch D2 and C2.
For your example, you can use the ExtInt (http://docs.micropython.org/en/latest/l ... xtInt.html) module to watch for a pin change on any of the 4 pins (Since X1 thru X4 are mapped to pins A0 thru A3.
The only way to read all 4 values at once is to use the stm module. You could do:
It only has a restricted sense of pin changed. You can watch for a particular pin changing, but you can only watch a single pin 0, and a single pin 1.
So you can watch D0 and C2, but you can't watch D2 and C2.
For your example, you can use the ExtInt (http://docs.micropython.org/en/latest/l ... xtInt.html) module to watch for a pin change on any of the 4 pins (Since X1 thru X4 are mapped to pins A0 thru A3.
The only way to read all 4 values at once is to use the stm module. You could do:
Code: Select all
import stm
val = stm.mem16[stm.GPIOA + stm.GPIO_IDR] & 0x0f
Re: Port groups and interrupts
Thanks dhylands. I was hopefully trying to stay as python(y) as possible but I suspect I can't avoid the lower level stuff completely.