Hi everyone,
I think I'm getting very close to understanding DT's interrupt routine but need some direction.
I'm using a PIC16F688 to make myself a test fixture to test some product but pretty sure I did something wrong in the setups.
Using this small test program and a scope to monitor an output, I see the "Toggling" led stop during the interrupt routine. This only happens when PAUSE, FOR/NEXT and PAUSEUS is used in the main.
Ultimately, I will need to send serial data using SEROUT2 continueously in the background so I can do other chores in the foreground that will use TMR1, A/D and some simple LED indications.
My understanding is that main program should not be disturbed by the interrupt routine if done properly. In this case, I'm hoping I'm not being proper rather than using the wrong PIC for my app.Code:'************************************************************************* '* Name : Test fixture.BAS '* Author : Louis Chagoya '* Notice : Copyright (c) 2008 Link M Technologies '* : All Rights Reserved '* Date : 8/24/2009 '* Version : 1.1 '* Notes : This system uses the PIC16F688 to learn DT's Interrupt system '* while utilizing other signalling functions at the same time. '************************************************************************* '///////////////////////////////////////////////////////////////////////// ' Configs '///////////////////////////////////////////////////////////////////////// @ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF OSCCON = %01100001 ' Oscillator set to 4MHz, bits 6-4 CMCON0 = 7 ' Analog comparators off ADCON0 = %10010000 ' A/D right justified, Vref=VDD, AN2 selected ADCON1 = %01010000 ' A/D conversion CLK/16 ANSEL = %00000100 ' AN2 set to analog input rest digital TRISA = %00101101 ' Set ports 0,2,3 and 5 as inputs, rest outputs TRISC = %00000000 ' Set all pins as outputs 'DEFINE OSC 8 ' Define OSC to 8Mhz for PAUSE setting DEFINE ADC_BITS 10 ' ADCIN resolution (Bits) DEFINE ADC_CLOCK 5 ' ADC clock source (Fosc/16) DEFINE ADC_SAMPLEUS 7 ' ADC sampling time (uSec) DEFINE SER2_BITS 8 ' Set up baud rate for 7812bps '///////////////////////////////////////////////////////////////////////// ' Pin I/O naming '///////////////////////////////////////////////////////////////////////// Data_In VAR PORTA.0 ' Pin 13 Data from UUT Data_Out VAR PORTA.1 ' Pin 12 Data to UUT ' VAR PORTA.2 ' Pin 11 GPS input from UUT Test VAR PORTA.3 ' Pin 4 Push button to begin test Bypass VAR PORTA.4 ' Pin 3 Puts UUT into Bypass or Active mode Byp_Sel VAR PORTA.5 ' Pin 2 Select type switch input BCDval var PORTC ' All of PortC declared as variable Ready VAR PORTC.0 ' Pin 10 READY LED Byp_Pass VAR PORTC.1 ' PIn 9 BYPASS test PASS LED - Green Byp_Fail VAR PORTC.2 ' PIn 8 BYPASS test FAIL LED - Red Act_Pass VAR PORTC.3 ' PIn 7 ACTIVE test PASS LED - Green Act_Fail VAR PORTC.4 ' PIn 6 ACTIVE test FAIL LED - Red Pwr_ON VAR PORTC.5 ' PIn 5 Provides power to UUT '///////////////////////////////////////////////////////////////////////// ' Variable declarations '///////////////////////////////////////////////////////////////////////// i VAR BYTE ' Increment counter when needed cksm VAR BYTE ' Checksum variable '///////////////////////////////////////////////////////////////////////// ' DT's Interrupt Routine '///////////////////////////////////////////////////////////////////////// INCLUDE "DT_INTS-14.bas" ' Base Interrupt System INCLUDE "ReEnterPBP.bas" ' Include if using PBP interrupts ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler TMR0_INT, _Gen_Data, PBP, YES endm INT_CREATE ; Creates the interrupt processor ENDASM '.....Various OPT_Reg tries.... 'OPTION_REG.3 = 1 ' Prescaler is assigned to the WDT 'OPTION_REG.2 = 1 ' N/G, even with WDT ON 'OPTION_REG.1 = 1 'OPTION_REG.0 = 1 ; REGISTER 5-1: Prescaler = 1:1 via WDT rate OPTION_REG = 7 ' Times out in 65.2ms. Will need 100ms when ' get it to work @ INT_ENABLE TMR0_INT ; enable Timer 0 interrupts cksm = 85 '///////////////////////////////////////////////////////////////////////// ' Main Program '///////////////////////////////////////////////////////////////////////// start: TOGGLE act_fail ' Use this output to monitor routine PAUSE 1 TOGGLE act_fail PAUSE 1 GOTO start '---[TMR0 - interrupt handler]-------------------------------------------- Gen_Data: SEROUT2 Data_out, 108, [cksm] ' Serial out cksm value at 7812bps PAUSEUS 3720 ' Total time= 5ms @ INT_RETURN END
Thank for your help...




Bookmarks