Still not clear on how to end the mismatch in porta. Tried the following code, but it did not work on the breadboard. I'm looking for the the led to go off and stay off for 2 seconds, and then the timing to resume. This is just a demo tryout.
All of this is just testing to try to understand how instant interrupts work. Of course I know it's possible to just poll a porta pin in the main loop ... I do it that way with my non-interrupt software.
431 wordsCode:'device is PIC 16F684 'set registers OPTION_REG.7 = 0 'enable porta pullups CMCON0 = 7 'comparators off ANSEL = 0 'porta pins all digital TRISA = %111111 'set porta pins as input TRISC = %001101 'set portc pins 0,2,3 as input, all others output OSCCON = %1110000 'set internal osc. at 8 mhz, wait for stable freq. OSCTUNE = 0 'internal osc. running at factory calibration DEFINE OSC 8 '8 Mhz oscillator while OSCCON.2 = 0 'wait for osc.to be stable wend 'declare variables led var portc.3 'led output on portc.3 DTtime var word sum var word dummy var byte start: low led 'flash red LED for 0.5 sec pause 500 input led pause 2000 'pause 2 seconds INCLUDE "DT_INTS-14 for F684.bas" 'Base interrupt with wsave selected for 16F684 INCLUDE "ReEnterPBP.bas" 'Using PBP interrupts INCLUDE "Elapsed_INT_RI.bas" 'Elasped timer counting seconds and tenths seconds ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler TMR1_INT, _ClockCount, PBP, yes INT_Handler RAC_INT, _RDT, PBP, yes endm INT_CREATE ; Creates the interrupt processor INT_ENABLE TMR1_INT ; Enable Timer 1 Interrupts INT_ENABLE RAC_INT ; Enable PortA Change Interrupt ENDASM dummy = porta ' initialize dummy variable DTtime = 1800 ' 180.0 second test Gosub ResetTime ' Reset Time to 0d-00:00:00.00 Gosub StartTimer ' Start the Elapsed Timer Main: low Led 'turn on led sum = 10*Seconds + Tenths if sum => DTtime then high led 'turn off led goto halt endif GOTO Main '-------Interrupt Handler for RDT------------ RDT: high led 'turn led off dummy = porta 'needed to end mismatch in porta pause 2000 'pause 2 seconds @ INT_RETURN '--------------------------------------------- halt: end




Bookmarks