I have TMR0 set to 8 bit mode actually T0CON = %11000111.
Changing the prescaler to either 128 or 64 seemed to speed it up. I can't seem to get to 60Hz no matter what I do.
I tried porting over your working code from the 16F648A and using DT_INTS-18 instead of 14, but get a whole bunch of compiler errors.
I notice that the code Bruce wrote using DT_INTS-18 didn't include the wsave varibles that the DT_INTS-14 looks to require?
I know I have workable code and should just leave it alone, but I want to learn how to make this work with CPP on the 18F2320.
As always, thank you!
Haven't tried this yet, but maybe it will work?:
Code:
INCLUDE "DT_INTS-18.bas" ; Base Interrupt System
INCLUDE "ReEnterPBP-18.bas" ; Include if using PBP interrupts
DEFINE OSC 20 ' Running with a 20MHz x-tal
' #CONFIG - doing this manually at the moment via programmer
ADCON1 = 7
TRISB = %11110111 ' Set PortB direction.
T0CON = %11000111 ' Prescaler assigned to TMR0, 1:256 ratio
TrigOut VAR PortB.3 ' Pin for 60Hz output
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler TMR0_INT, _ISR, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM
@ INT_ENABLE TMR0_INT ; Enable the 120Hz interrupt for the square wave generator.
Main:
Pause 2000
HSEROUT["Is This Working???",10,13]
Goto Main
ISR:
If TrigOut = 0 THEN ' If trig output is low....
TrigOut = 1 ' Set trig output high
ELSE
TrigOut = 0 ' Trig output was high, set it low.
ENDIF
TMR0 = TMR0 + 94 ' Reload TMR0 for 120Hz interrupt rate
@ INT_RETURN
'-------------------------------------------------------------------------------
Bookmarks