list p=16f877                 ; list directive to define processor      

#include <p16f877.inc>        ; processor specific variable definitions    

 __CONFIG _CP_OFF & _WDT_OFF & _BODEN_ON & _PWRTE_ON & _HS_OSC & _WRT_ENABLE_ON & _CPD_OFF & _LVP_ON

 

 

cblock 0x20

 COUNTH

  COUNTM

  COUNTL

endc

         ORG       0x0000     ;RESET vector must always be at 0x00        

 goto      init       ;Just jump to the main code section.
;***************************************

; Initialize Pins

;***************************************

init         clrf      INTCON         ; No interrupts

bsf       STATUS,RP0     ; select bank 1 movlw 0x07 movwf ADCON1

clrf      TRISA          ; All port A is output              

bcf       STATUS,RP0     ; select bank 0        

clrf      PORTA

;***************************************;

Main code

;***************************************

Main bcf PORTA,0

  bsf PORTA,2


clock

bsf PORTA,1

call Delay

bcf PORTA,1

call Delay

goto clock

 

goto $


;***************************************

;Delay 0.0015s

;***************************************

Delay ;2498 cycles

movlw 0xED

movwf COUNTH

movlw 0x03

movwf COUNTM

Delay_0

decfsz COUNTH, f

goto $+2

decfsz COUNTM, f

goto Delay_0
;2 cycles

goto $+1

return        

 END

Views: 94

Comment

You need to be a member of Personal Mechatronics Lab to add comments!

Join Personal Mechatronics Lab

© 2022   Created by PML.   Powered by

Badges  |  Report an Issue  |  Terms of Service