P16F877A ile Display Örnegi
Amacımız P16F877A da Display e birer saniye aralıklarla 0-9 arasında saydırmak.Bunun için Timer0 sayıcıyı ,ortak katotlu display kullandım.
Programımızın .asm asagıdaki gibidir :
list p =16F877A include <P16F877A.inc> timersayac EQU 0x21 displaysayac EQU 0x22
org 0x00 goto START org 0x04 BTFSC INTCON,TMR0IF;Timer0 Kesmesi mi? goto KESME goto DON KESME BANKSEL INTCON bcf INTCON,TMR0IF BANKSEL TMR0 movlw d'6' movwf TMR0;timer0 baslangıc degeri DECF timersayac,1 BTFSS STATUS,Z retfie MOVLW d'10' subwf displaysayac,W btfsc STATUS,Z call sayacsifir movf displaysayac,W call LOOKUPTABLE movwf PORTD incf displaysayac,1 retfie LOOKUPTABLE addwf PCL,1 RETLW B'00111111';0 RETLW B'00000110';1 RETLW B'01011011';2 RETLW B'01001111';3 RETLW B'01100110';4 RETLW B'01101101';5 RETLW B'01111101';6 RETLW B'00000111';7 RETLW B'01111111';8 RETLW B'01100111';9 START BANKSEL INTCON movlw B'10100000';timer0 kesmesini aktif et movwf INTCON BANKSEL OPTION_REG movlw B'00000101';timer0 prescaler degeri movwf OPTION_REG BANKSEL TMR0 movlw d'6' movwf TMR0 movlw d'125' movwf timersayac movlw d'0' movwf displaysayac BANKSEL TRISD movlw B'00000000' movwf TRISD DON goto DON sayacsifir movlw d'0' movwf displaysayac return end
Programımızın Proteus Seması
Programımızın .asm asagıdaki gibidir :
list p =16F877A include <P16F877A.inc> timersayac EQU 0x21 displaysayac EQU 0x22
org 0x00 goto START org 0x04 BTFSC INTCON,TMR0IF;Timer0 Kesmesi mi? goto KESME goto DON KESME BANKSEL INTCON bcf INTCON,TMR0IF BANKSEL TMR0 movlw d'6' movwf TMR0;timer0 baslangıc degeri DECF timersayac,1 BTFSS STATUS,Z retfie MOVLW d'10' subwf displaysayac,W btfsc STATUS,Z call sayacsifir movf displaysayac,W call LOOKUPTABLE movwf PORTD incf displaysayac,1 retfie LOOKUPTABLE addwf PCL,1 RETLW B'00111111';0 RETLW B'00000110';1 RETLW B'01011011';2 RETLW B'01001111';3 RETLW B'01100110';4 RETLW B'01101101';5 RETLW B'01111101';6 RETLW B'00000111';7 RETLW B'01111111';8 RETLW B'01100111';9 START BANKSEL INTCON movlw B'10100000';timer0 kesmesini aktif et movwf INTCON BANKSEL OPTION_REG movlw B'00000101';timer0 prescaler degeri movwf OPTION_REG BANKSEL TMR0 movlw d'6' movwf TMR0 movlw d'125' movwf timersayac movlw d'0' movwf displaysayac BANKSEL TRISD movlw B'00000000' movwf TRISD DON goto DON sayacsifir movlw d'0' movwf displaysayac return end
Programımızın Proteus Seması
Yorumlar
Yorum Gönder