I have pic18f2550 datasheet in hand , knowing how to use it . But now I was using it in
my LCR digital bridge design , the USB function was completely disabled .
The following was my assembly built to test the PWM sine generator :
;Loading value Sin (2*PI*t/20) in registers of porosity SHIM CCPR2L:CCPCON <5:4>
Load_Sine_Val
movlw HIGH Sine_Table
movwf PCLATH
movf Sine_step,W
mullw .2
movf PRODL,W ; index should be (w*2)
call Sine_Table
mullw .1 ; wonderful => make sine generation stable
movf PRODL,W
movwf Sine_val
movlw b'11001111'
andwf CCP2CON,f
rrcf Sine_val, F
btfsc STATUS, C
bsf CCP2CON, 4 ;Duration is SHIM, low-order bit (0)
rrcf Sine_val, F
btfsc STATUS, C
bsf CCP2CON, 5 ;Duration is SHIM, bit N 1
movf Sine_val, W
andlw 0x3F
movwf CCPR2L ;Duration is SHIM - rest , don't use cppr2l,1
decfsz Sine_step,F ;Following step
goto lsv_1 ;For alignment of duration in sequence
movlw .20 ;New period
movwf Sine_step
return
lsv_1 nop ;for alignments of duration in sequence
return
|