Hello, I've trying to put the gpio interrupt to work but without much success.
The code turn the GPIO interrupt on, the pin as input and goes to a while 1. But it is never calling the __p function. Have any one used GPIO interrupts up to now? Here is a snippet of the code: ------------------------------------------------------------------------------------------------------------- function __p() print "I'm a GPIO interrupt" end pio.pin.setdir( pio.INPUT, pio.P7_6) cpu.set_int_handler( cpu.INT_GPIO_NEGEDGE, __p ) cpu.sei( cpu.INT_GPIO_NEGEDGE, pio.P7_6 ) function __test() while true do if uart.getchar( 0, 0 ) ~= "" then break end end end __test() ------------------------------------------------------------------------------------------------------------- -- Best, Marcelo _______________________________________________ eLua-dev mailing list [hidden email] https://lists.berlios.de/mailman/listinfo/elua-dev |
Hi,
On Tue, Oct 4, 2011 at 11:46 PM, Marcelo Politzer <[hidden email]> wrote: Hello, I've trying to put the gpio interrupt to work but without much success. Since it's quite hard for me to test this, please do this: 1. edit src/platform/str9/platform_int.c 2. locate function "exint_irq_handler"
3. add this line at the beginning: platform_s_uart_send( CON_UART_ID, '@' ); This will send a '@' char on the UART when the interrupt handler is called. If you try to generate an interrupt by changing the pin's logic level and you can't see a '@' on the terminal it means that the interrupt never gets through and we'll have a good starting point. If you see a '@' we'll have another good starting point :)
Also, try with INT_GPIO_POSEDGE instead of INT_GPIO_NEGEDGE, does anything change? Best, Bogdan ------------------------------------------------------------------------------------------------------------- _______________________________________________ eLua-dev mailing list [hidden email] https://lists.berlios.de/mailman/listinfo/elua-dev |
Ok, I'll try it out and post the answer.
Probably not until Thursday, tomorow is a holly day here and I don't have this kit @home. 2011/10/11 Bogdan Marinescu <[hidden email]>: > Hi, > > On Tue, Oct 4, 2011 at 11:46 PM, Marcelo Politzer <[hidden email]> > wrote: >> >> Hello, I've trying to put the gpio interrupt to work but without much >> success. >> >> The code turn the GPIO interrupt on, the pin as input and goes to a while >> 1. >> But it is never calling the __p function. Have any one used GPIO >> interrupts >> up to now? >> >> Here is a snippet of the code: >> >> ------------------------------------------------------------------------------------------------------------- >> function __p() >> print "I'm a GPIO interrupt" >> end >> >> pio.pin.setdir( pio.INPUT, pio.P7_6) >> >> cpu.set_int_handler( cpu.INT_GPIO_NEGEDGE, __p ) >> cpu.sei( cpu.INT_GPIO_NEGEDGE, pio.P7_6 ) >> >> function __test() >> while true do >> if uart.getchar( 0, 0 ) ~= "" then break end >> end >> end >> >> __test() > > Since it's quite hard for me to test this, please do this: > 1. edit src/platform/str9/platform_int.c > 2. locate function "exint_irq_handler" > 3. add this line at the beginning: > platform_s_uart_send( CON_UART_ID, '@' ); > This will send a '@' char on the UART when the interrupt handler is called. > If you try to generate an interrupt by changing the pin's logic level and > you can't see a '@' on the terminal it means that the interrupt never gets > through and we'll have a good starting point. If you see a '@' we'll have > another good starting point :) > Also, try with INT_GPIO_POSEDGE instead of INT_GPIO_NEGEDGE, does anything > change? > Best, > Bogdan >> >> >> ------------------------------------------------------------------------------------------------------------- >> >> -- >> Best, >> Marcelo >> _______________________________________________ >> eLua-dev mailing list >> [hidden email] >> https://lists.berlios.de/mailman/listinfo/elua-dev > > > _______________________________________________ > eLua-dev mailing list > [hidden email] > https://lists.berlios.de/mailman/listinfo/elua-dev > > -- []s, Marcelo _______________________________________________ eLua-dev mailing list [hidden email] https://lists.berlios.de/mailman/listinfo/elua-dev |
Ok, I did some testing, here are the results:
After running the Lua script below, I started up GDB and set a breakpoint to "exint_irq_handler", after pressing the button nothing happened. Tried both POSEDGE and NEGEDGE. I also did tried adding the "platform_s_uart_send" function, but it doesn't seem to exist. I tried with "platform_uart_send", but also without success. I'll take a look into the initialization part of the interrupt but as I'm quite unfamiliar with the str9, any help is more than welcome. This is the Lua part used: ------------------------------------------------------------------------------------------ function __p() print "I'm a GPIO interrupt" end function init() pio.pin.setdir( pio.INPUT, pio.P7_6) cpu.set_int_handler( cpu.INT_GPIO_NEGEDGE, __p ) cpu.sei( cpu.INT_GPIO_NEGEDGE, pio.P7_6 ) end function __test() local b init() while true do b = btn.getbtn() if (b) then print ("ok") end if uart.getchar( 0, 0 ) ~= "" then break end end end __test() --------------------------------------------------------------------------------------- 2011/10/11 Marcelo Politzer <[hidden email]>: > Ok, I'll try it out and post the answer. > > Probably not until Thursday, tomorow is a holly day here and I don't > have this kit > @home. > > 2011/10/11 Bogdan Marinescu <[hidden email]>: >> Hi, >> >> On Tue, Oct 4, 2011 at 11:46 PM, Marcelo Politzer <[hidden email]> >> wrote: >>> >>> Hello, I've trying to put the gpio interrupt to work but without much >>> success. >>> >>> The code turn the GPIO interrupt on, the pin as input and goes to a while >>> 1. >>> But it is never calling the __p function. Have any one used GPIO >>> interrupts >>> up to now? >>> >>> Here is a snippet of the code: >>> >>> ------------------------------------------------------------------------------------------------------------- >>> function __p() >>> print "I'm a GPIO interrupt" >>> end >>> >>> pio.pin.setdir( pio.INPUT, pio.P7_6) >>> >>> cpu.set_int_handler( cpu.INT_GPIO_NEGEDGE, __p ) >>> cpu.sei( cpu.INT_GPIO_NEGEDGE, pio.P7_6 ) >>> >>> function __test() >>> while true do >>> if uart.getchar( 0, 0 ) ~= "" then break end >>> end >>> end >>> >>> __test() >> >> Since it's quite hard for me to test this, please do this: >> 1. edit src/platform/str9/platform_int.c >> 2. locate function "exint_irq_handler" >> 3. add this line at the beginning: >> platform_s_uart_send( CON_UART_ID, '@' ); >> This will send a '@' char on the UART when the interrupt handler is called. >> If you try to generate an interrupt by changing the pin's logic level and >> you can't see a '@' on the terminal it means that the interrupt never gets >> through and we'll have a good starting point. If you see a '@' we'll have >> another good starting point :) >> Also, try with INT_GPIO_POSEDGE instead of INT_GPIO_NEGEDGE, does anything >> change? >> Best, >> Bogdan >>> >>> >>> ------------------------------------------------------------------------------------------------------------- >>> >>> -- >>> Best, >>> Marcelo >>> _______________________________________________ >>> eLua-dev mailing list >>> [hidden email] >>> https://lists.berlios.de/mailman/listinfo/elua-dev >> >> >> _______________________________________________ >> eLua-dev mailing list >> [hidden email] >> https://lists.berlios.de/mailman/listinfo/elua-dev >> >> > > > > -- > []s, > Marcelo > -- Best, Marcelo _______________________________________________ eLua-dev mailing list [hidden email] https://lists.berlios.de/mailman/listinfo/elua-dev |
Free forum by Nabble | Edit this page |