jcR 6 Posted January 31, 2013 Share Posted January 31, 2013 Whats are the pins and Interrupts for Stellarich Launchpad to use with this function: attachInterrupt(interrupt, function, mode)Thanks JCR Quote Link to post Share on other sites
Bernard 7 Posted February 2, 2013 Share Posted February 2, 2013 Hello JCR, Contrary to arduino documentation on Stellaris you can use all GPIO pins as first argument of the "attachinterrupt function" ex: attachInterrupt (PB_3, isrFunction, mode); Here is an example using PUSH1 on PF_4 that toggle RED_LED /* Test interruption et antirebond */ unsigned long DebounceTime; unsigned long LastDebounceTime = 0; volatile int FlagStateRedLed = LOW; volatile int FlagStateGreenLed = LOW; void setup() { Serial.begin(9600); pinMode(RED_LED, OUTPUT); pinMode(PUSH1, INPUT_PULLUP); attachInterrupt(PUSH1, ChangeStateRedLed, FALLING); } void loop() { for (int i = 0; i < 100; i++) { Serial.println(" Waiting for push1 pressed"); delay(10); } } void ChangeStateRedLed() { DebounceTime = millis(); if ( DebounceTime - LastDebounceTime > 200 || DebounceTime < LastDebounceTime) { FlagStateRedLed = !FlagStateRedLed; digitalWrite(RED_LED, FlagStateRedLed); LastDebounceTime = DebounceTime; } } Hope this help Cheers Bernard jcR 1 Quote Link to post Share on other sites
jcR 6 Posted February 4, 2013 Author Share Posted February 4, 2013 Hi Bernard thanks for the response. I have tested the following (not good for interrupt but ok for demo!) volatile int state = HIGH; void setup() { Serial.begin(9600); pinMode(RED_LED, OUTPUT); attachInterrupt(RED_LED, blink, CHANGE); } void loop() { digitalWrite(RED_LED, state); } void blink() { state = !state; Serial.println("T"); delay(50); } Quote Link to post Share on other sites
Lord anubis 1 Posted February 7, 2013 Share Posted February 7, 2013 Hi, where did you find inf o about attachInterrupt? I did do a google search like "stellaris attachInterrupt" and I found this topic. Quote Link to post Share on other sites
jcR 6 Posted February 9, 2013 Author Share Posted February 9, 2013 Hi This is why I asked the question. Documentation of the arduino is not functioning with the Stellaris Launchpad and brownfox gave me a solution that works perfectly. JC @ brownfox who did you find the solution ? Quote Link to post Share on other sites
Bernard 7 Posted February 9, 2013 Share Posted February 9, 2013 Hi, Sometimes using Arduino doc for Stellaris is confusing. Arduino interrupts are numbered Board int.0 int.1 int.2 int.3 int.4 int.5 Uno, Ethernet 2 3 Mega2560 2 3 21 20 19 18 Leonardo 3 2 0 1 Having a look at WInterrupts.c helped me to understand attachInterrupt function on Stellaris void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode) uint8_t bit = digitalPinToBitMask(interruptNum); uint8_t port = digitalPinToPort(interruptNum); uint32_t portBase = (uint32_t) portBASERegister(port); So on Stellaris we use pin name. Maybe interruptNum should be replaced by interruptPin ... just a suggestion. That being said I like Energia In the exemple above ( PUSH1, PF_4, 31) refer to the same pin ( see pins_energia.h) Cheers Bernard Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.