- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I was wandering if anyone could help me set up an interrupt on one of the GPIO pins, I've tried my self by following the hardware interface guide and i can't see where I've gone wrong. this is the code I've added to try and set this up. Whenever I try to compile i get to few arguments to function gpio_registerForInterrupt. Thanks
#define dial GPIO_PIN_P15
gpio_configurePin(0,dial,GPIO_EN_INT_RISING_EDGE|GPIO_PULL_DOWN,GPIO_PIN_INPUT_HIGH);
void hello_sensor_create(void)
{
//each bit corresponds to a port for port 0 - 3
UINT16 interrupt_handler_mask[3] = {0,0,0};
//0 is the port with pin 15
interrupt_handler_mask[0] |= (1 << dial);
//register interrupt handler
gpio_registerForInterrupt(interrupt_handler_mask,interrupt_gpio,NULL);
}
void interrupt_gpio(void*){
if(led_on == FALSE){
gpio_setPinOutput(0,LED,GPIO_PIN_OUTPUT_HIGH);
gpio_setPinOutput(0,RGB,GPIO_PIN_OUTPUT_HIGH);
led_on = TRUE;
}else{
gpio_setPinOutput(0,LED,GPIO_PIN_OUTPUT_LOW);
gpio_setPinOutput(0,RGB,GPIO_PIN_OUTPUT_LOW);
led_on = FALSE;
}
}
Solved! Go to Solution.
- Labels:
-
GPIO
- Tags:
- gpio interrupt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello.
When you are initializing the mask array, try changing the "or" statement to an assignment.
I did a quick demo app of what I think is what you are trying to do.
The external button will turn the external LED on and off, while the on-board button will do the same for the on-board LED.
Take a look at it for reference.
Please let us know if this solved your problem.
Thank you.
James
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
s.muyaba try taking a look at WICED Smart User's Guide -> GPIO -> interrupts. First link should be sufficient to answer your question.
-Kevin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The GPIOs you use to toggle the LEDs must be configured before you can use the setPinOutput functions.
Example: gpio_configurePin(0, LED, GPIO_OUTPUT_ENABLE | GPIO_INPUT_DISABLE, 1);
Give that a shot, if it's not the problem we can isolate it to the interrupt configuration and go from there.
Jacob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello, your interrupt handler function is wrong : void interrupt_gpio(void*)
It has too few arguments.
It should be: void interrupt_gpio(void *parameter, UINT8 arg)
Hope that helped.
James
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, this allowed me to compile the code . even though both by interrupts, external and on board button are firing they it seems that every time the external interrupt occurs the one for the on board button is also being handled, I'm assuming this is because they are on the same port, if I'm correct is there a way to handle interrupts according to pins and not ports? The module also seems to crash and become unresponsive requiring a reboot since i started using the interrupt, any idea what could cause this? out of curiosity, how long did it take for some of you to get familiar with the module?
cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just curious, what module/board are you using?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm using the BCM20736S module from embeddedmasters (fdroberts2), I was asking so I can better estimate how long it might take me to implement solutions, I'm a recent graduate and most of my experience is on arduino, the MSP430 and some FPGAs. I got it working late last night after going through all the links provided here and reading related posts. After removing the on board button interrupt I realised the reason I was having issues was I wasn't setting up a second interrupt mask for my external button, seems dumb now but it wasn't made very clear in the hardware interfaces document that this was necessary, but the interrupt seems to fire twice though?. Thanks for all your help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
s.muyaba not quite sure what your problem is but
instead of
gpio_configurePin(0,dial,GPIO_EN_INT_RISING_EDGE|GPIO_PULL_DOWN,GPIO_PIN_INPUT_HIGH);
try:
gpio_configurePin(0, dial, GPIO_EN_INT_RISING_EDGE, GPIO_PIN_OUTPUT_LOW);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
s.muyaba sorry typo in my last response, please check response again, (gpio_configurePin(0, dial, GPIO_EN_INT_RISING_EDGE, GPIO_PIN_OUTPUT_LOW);)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Unfortunately that didn't work either, the interrupt is getting fired on both edge regardless of specifying an edge, is it possible that I maybe missed a configuration parameter to limit the interrupts to just one edge?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My code hasn't changed, the only change I've made has been to the pin configuration
gpio_configurePin(0, dial, GPIO_EN_INT_RISING_EDGE, GPIO_PIN_OUTPUT_LOW);
and this hasn't changed anything. I've made a temporary fix by checking that the pin is actually high and this works but I have concern about latency if the pin state was being toggled rapidly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
have you taken a look at james's code? It works fine with his setup
We're having a hard time pinpointing where you are going wrong.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've sort of switched tasks atm but I'll be moving back to this next week and I'll update with any new changes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello.
When you are initializing the mask array, try changing the "or" statement to an assignment.
I did a quick demo app of what I think is what you are trying to do.
The external button will turn the external LED on and off, while the on-board button will do the same for the on-board LED.
Take a look at it for reference.
Please let us know if this solved your problem.
Thank you.
James