;******************************************************************************* ; Filename: Servo206.asm * ;******************************************************************************* list p=10f206 #include __CONFIG _CP_OFF & _MCLRE_OFF & _WDT_OFF & _IntRC_OSC ;***** VARIABLE DEFINITIONS **************************************************** cblock 0x08 pulscntr loopcntr endc #define SERVO GPIO,0 ;***** INITIALIZE ************************************************************** ORG 0x000 Init movwf OSCCAL ; update register with factory calibration value clrf GPIO clrf CMCON0 movlw b'00111110' ; GP0 = output TRIS GPIO movlw b'11000110' ; prescaler set to 128, assigned to TMR0 OPTION goto Main ;***** SUBROUTINES ************************************************************* Dly call Dly4us Dly4us retlw 0x00 ;****** MAIN LOOP ************************************************************** Main incf loopcntr ; Increase counter every loop bsf SERVO ; Start pulse movlw 0x60 ; Load TMR0 for 90 * 128us +/- 11ms ??? movwf TMR0 ; movlw 0x6E ; Set left position (min 0x30) btfsc loopcntr,5 ; Change position every 16 timerloops movlw 0x70 ; Set right position (max 0xD0) movwf pulscntr PlsLoop call Dly ; Delay 8us * cntr decfsz pulscntr goto PlsLoop bcf SERVO ; Stop pulse TmrLoop movfw TMR0 ; read TMR0 until 0x00 btfss STATUS,Z goto TmrLoop goto Main ;***** EPILOGUE **************************************************************** ORG 0x1F0 DE 'S','e','r','v','o','2','0','6','-','0','0','2' END