In SX Microcontrollers, SX/B Compiler and SX-Key Tool, John Kauffman wrote: File is self-explanatory, I think. Symptom: LED stays on. ' ========================================================================= ' ' File...... INT-RTCC-01.SXB ' Purpose... Demonstrate simple use of interupt triggered by RTCC ' Author.... John Kauffman ' E-mail.... ' Started... ' Updated... 2006 04Apr 12 - 17:42 ' ' ========================================================================= ' ------------------------------------------------------------------------- ' Program Description ' ------------------------------------------------------------------------- ' Purpose = Demonstrate simple use of interupt triggered by RTCC ' objective: divide down RTCC interupts until one flash per 4 seconds. ' 4,000,000 / 256 / 256 / 256 = 0.25 = once per 4 seconds. ' RTCC prescaler set to 256 ' INterupt increments ISRCOunter by 1 ' In MAIN program when ISRCOUnter = 255 then increment ISRMultiplier1 ' In MAIN program when ISRMultiplier1 = 255 then increment ISRMultiplier2 ' When ISRMultiplier2 gets to 255 LED flashes ' ------------------------------------------------------------------------- ' Device Settings ' ------------------------------------------------------------------------- DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX FREQ 4_000_000 ' ------------------------------------------------------------------------- ' IO Pins ' ------------------------------------------------------------------------- LED VAR RC.0  ' LED circuit: ' RC.0 - 470ohm - LEDcath - LEDanode - Vdd ' ------------------------------------------------------------------------- ' Constants ' ------------------------------------------------------------------------- ' ------------------------------------------------------------------------- ' Variables ' ------------------------------------------------------------------------- ISRCounter VAR byte ISRMultiplier1 VAR byte ISRMultiplier2 VAR byte ' ========================================================================= INTERRUPT ISR_Start: ISRCounter = ISRCounter + 1 ISR_Exit: RETURNINT ' {cycles} ' ========================================================================= PROGRAM Start Start: 'Pin 76543210 ' Following line sets only RC.0 (LED) to be an output TRIS_C = $11111110 'Alternate = $FE OPTION = $100000111 'bit 76543210 ' option bits (left-7 to right-0) ' RTW 1 = RTCC ( not W) ' RTI 0 = RTCC roll-over interupt is enabled ' RTS 0 = Increment is form internal cycle (not expternal pin) ' RTE 0 = Increments on low to high transition (should have no effect since not on pin ' PSA 0 = Prescaler assigned to RTCC (not W) ' 1 = Prescaler = 1:256 ' 1 = Prescaler = 1:256 ' 1 = Prescaler = 1:256 Main: ' 4_000_000 / 256 / 256 /256 = 0.238 = once per 4 seconds ' first divide by 256 is in prescaler IF ISRCOUnter = 255 Then ISRMultiplier1 = ISRMultiplier1+1 IF ISRMultiplier1 = 255 THen ISRMultiplier2 = ISRMultiplier2+1 IF ISRMultiplier2 = 255 THen HIGH LED Pause 500 LOW LED Endif Endif Endif ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=120370 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)