In SX Microcontrollers, SX/B Compiler and SX-Key Tool, basicstampede wrote: I am learning about Interrupt on SX/B. So I want a simple program. I have two LEDs. The main program will blink one LED on & off. When SX senses a keypress (on a RB pin), then I want the ISR to run (toggle a different LED). I wrote the below code, but I must be missing some code (e.g. setting up RB port for interrupt, for setting high to low transition) etc. Can someone please modify this program? The purpose section has more details of what I want. I also attach the file. ' ========================================================================= ' ' File...... TEMPLATE.SXB ' Purpose... to learn about external interrupt ' Author.... ' E-mail.... ' Started... 5 Sept. 2008 ' Updated... ' ' ========================================================================= ' ------------------------------------------------------------------------- ' Program Description ' ------------------------------------------------------------------------- ' there are two LEDs, a green LED on RB.5 and a red LED on RB.6 ' and there is 1 input switch connected to RB.6 ' the main program will blink green LED 1 sec. on and 1 sec. off continuously ' when user presses the input switch (falling edge), go into ISR ' in ISR, toggle the red LED and exit ISR ' ------------------------------------------------------------------------- ' Device Settings ' ------------------------------------------------------------------------- DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX FREQ 4_000_000 ' ------------------------------------------------------------------------- ' IO Pins ' ------------------------------------------------------------------------- IntSource RB.4 INPUT LED_Main RB.5 OUTPUT LED_ISR RB.6 OUTPUT ' ------------------------------------------------------------------------- ' Constants ' ------------------------------------------------------------------------- ' ------------------------------------------------------------------------- ' Variables ' ------------------------------------------------------------------------- ' ------------------------------------------------------------------------- INTERRUPT ' ------------------------------------------------------------------------- ISR_Start: ' ISR code here TOGGLE LED_ISR ISR_Exit: RETURNINT ' {cycles} ' ========================================================================= PROGRAM Start ' ========================================================================= Pgm_ID: ' ------------------------------------------------------------------------- ' Subroutines / Functions Declaration ' ------------------------------------------------------------------------- ' ------------------------------------------------------------------------- ' Program Code ' ------------------------------------------------------------------------- Start: ' initialization code here Main: ' main code here HIGH LED_Main PAUSE 1000 LOW LED_Main PAUSE 1000 GOTO Main ' ------------------------------------------------------------------------- ' Subroutines / Functions Listing ' ------------------------------------------------------------------------- ' ------------------------------------------------------------------------- ' User Data ' ------------------------------------------------------------------------- ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=291549 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)