languer - tks, I'd actually seen that previously in the datasheet, but couldn't immediately work out how to apply it, then I forgot about it.
Bert - phase project has been parked up.
Meanwhile, this ongoing problem is going to turn out so easy that I'll never be able to show my face on here again.
Ok, the latc didn't work, so I'm using a basic toggle, here the stripped back code...
Code:
@ __CONFIG _CONFIG1, _FCMEN_OFF & _FOSC_INTOSC & _WDTE_OFF & _MCLRE_OFF & _CP_OFF & _IESO_OFF & _BOREN_OFF & _PWRTE_OFF & _LVP_OFF & _CLKOUTEN_OFF
@ __CONFIG _CONFIG2, _LVP_OFF & _PLLEN_OFF
INCLUDE "DT_INTS-14.bas" ' Base Interrupt System
INCLUDE "ReEnterPBP.bas" ' Include if using PBP interrupts
Osccon = %01110010 'Osc 8Mhz
DEFINE OSC 8
DEFINE NO_CLRWDT 1 ' PBP doesn't clear WDT automatically
'16F1828 Pin Connections*********************************************
TRISC.4 = 0 '6 RC4 Main Output
'**********************************************************************
CM1CON0 = 0 ' COMPARATORS OFF
CM2CON0 = 0 ' COMPARATORS OFF
ADCON0 = 0
ADCON1 = 0
ANSELA = 0 ; All Port A ports to be digital
ANSELB = 0 ; All Port B ports to be digital
ANSELC = 0 ; All Port B ports to be digital
txsta = %10100100 'needed to turn on pin 10 as valid HSerout pin.
WPUA = 0 'weak pullups disabled.
WPUB = 0 'weak pullups disabled.
WPUC = 0 'weak pullups disabled.
'Timer2 Registers:
'Prescaler=1:1; TMR2 PostScaler=1:1; PR2=66 - Freq = 30,303.0303Hz - Period = 33,000 ns
T2CON.6 = 0 ' bits 6-3 Post scaler 1:1 thru 1:16
T2CON.5 = 0
T2CON.4 = 0
T2CON.3 = 0
T2CON.2 = 1 ' Timer2 on bit: 1=Timer2 is on;
T2CON.1 = 0 ' bits 1-0 Prescaler Rate Select bits
T2CON.0 = 0
PR2 = 66 ' PR2 (Timer2 Match value)
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler TMR2_INT, _Bert_ISR, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM
@ INT_ENABLE TMR2_INT ; enable Timer 0 interrupts
;----[Main Program Loop]------------------------------------------------------------------
BMAIN: 'make this your new temporary main for this test
toggle portc.4 'pin 6 (blue scope trace)
'LATC = LATC ^ %00001000 ' this assumes you can use portc.4 as an output.
GOTO BMAIN
'---[TMR2 - interrupt handler]--------------------------------------------------
Bert_ISR:
@ INT_DISABLE TMR2_INT ; enable Timer 0 interrupts
toggle PortC.3 'pin 7 (yellow scope trace)
'LATC = LATC ^ %00000100 ' this will toggle portc.3
@ INT_ENABLE TMR2_INT ; enable Timer 0 interrupts
@ INT_RETURN
end
& here's the result....
green trace is the main loop toggle (port C.4) with a frequency of just 1kHz(!!!) & the yellow trace is the ISR toggle (port C.3)with a frequency that's higher at 12Khz(!!!) , I have not got one clue what is going on here - it feels like 'week one - intro to PICs' all over again!
Bookmarks