Code:
define OSC 4
Wsave var byte $70system
Wsave1 var byte $A0system
Wsave2 var byte $120system
Wsave3 var byte $1A0system
'pointer for phase one in sinearray
'pointer for phase two in sine array
ADCON0 = %00000000
ADCON1 = %00000000
LED1 VAR PORTB.1
TRISB = %11111101
TRISC = %11111001 'PMW output for CCP1 AND CCP2
TRISA = %11111111
PR2 = 199 'set for 5Khz HPWM
CCP1CON = %00001100 'set CCP1 for PWM OPERATION
CCP2CON = %00001100 'set CCP2 for PWM OPERATION
T2CON = %00000100 'TIMER2ON and prescale of 1:1
index var byte
temp var word
timerone var word
INCLUDE "DT_INTS-14.bas" ; Base Interrupt System emp
INCLUDE "ReEnterPBP-14.bas"
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler TMR1_INT, _TEST, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM
T1CON = 000001 ; Prescaler = 1;1, TMR1 ON
@ INT_ENABLE TMR1_INT ; Enable Timer 1 Interrupts
timerone = 64980 ;gives about 50 htz sine
Main:
PAUSE 5
GOTO Main
TEST:
T1CON = 000000 'stop the timer
TMR1L = timerone.byte0 'reload the timer
TMR1H = timerone.byte1
T1CON = 000001 ' start the timer
gosub display
CCP1CON.4 = Temp.0 ' bit 0
CCP1CON.5 = Temp.1 ' bit 1
CCPR1L = Temp>>2 'Bit 2-7
index=index+1
if index =36 then index =0
@ INT_RETURN
display:
lookup index,[115,102,90,79,70,62,57,53,52,53,57,62,70,79,90,102,115,128,141,154,166,177,186,194,199,203,204,203,199,194,186,177,166,154,141,128],temp
return 'return to the subroutine
return 'return to the original GOSUB
thankx
Bookmarks