Created
March 6, 2014 00:11
-
-
Save chukitow/9379479 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;********************************************************************** | |
| ; This file is a basic code template for assembly code generation * | |
| ; on the PIC16F877A. This file contains the basic code * | |
| ; building blocks to build upon. * | |
| ; * | |
| ; Refer to the MPASM User's Guide for additional information on * | |
| ; features of the assembler (Document DS33014). * | |
| ; * | |
| ; Refer to the respective PIC data sheet for additional * | |
| ; information on the instruction set. * | |
| ; * | |
| ;********************************************************************** | |
| ; * | |
| ; Filename: xxx.asm * | |
| ; Date: * | |
| ; File Version: * | |
| ; * | |
| ; Author: * | |
| ; Company: * | |
| ; * | |
| ; * | |
| ;********************************************************************** | |
| ; * | |
| ; Files Required: P16F877A.INC * | |
| ; * | |
| ;********************************************************************** | |
| ; * | |
| ; Notes: * | |
| ; * | |
| ;********************************************************************** | |
| list p=16f877A ; list directive to define processor | |
| #include <p16f877A.inc> ; processor specific variable definitions | |
| __CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _XT_OSC & _WRT_OFF & _LVP_OFF & _CPD_OFF | |
| ; '__CONFIG' directive is used to embed configuration data within .asm file. | |
| ; The lables following the directive are located in the respective .inc file. | |
| ; See respective data sheet for additional information on configuration word. | |
| ;***** VARIABLE DEFINITIONS} | |
| var5 EQU 0x77 | |
| sum EQU 0X78 | |
| contador EQU 0X79 | |
| VAR1 EQU 0X7C | |
| VAR2 EQU 0X7A | |
| VAR3 EQU 0X7B | |
| w_temp EQU 0x7D ; variable used for context saving | |
| status_temp EQU 0x7E ; variable used for context saving | |
| pclath_temp EQU 0x7F ; variable used for context saving | |
| ;********************************************************************** | |
| ORG 0x000 ; processor reset vector | |
| nop ; nop required for icd | |
| goto main ; go to beginning of program | |
| ORG 0x004 ; interrupt vector location | |
| movwf w_temp ; save off current W register contents | |
| movf STATUS,w ; move status register into W register | |
| movwf status_temp ; save off contents of STATUS register | |
| movf PCLATH,w ; move pclath register into w register | |
| movwf pclath_temp ; save off contents of PCLATH register | |
| ; isr code can go here or be located as a call subroutine elsewhere | |
| movf pclath_temp,w ; retrieve copy of PCLATH register | |
| movwf PCLATH ; restore pre-isr PCLATH register contents | |
| movf status_temp,w ; retrieve copy of STATUS register | |
| movwf STATUS ; restore pre-isr STATUS register contents | |
| swapf w_temp,f | |
| swapf w_temp,w ; restore pre-isr W register contents | |
| retfie ; return from interrupt | |
| main | |
| ; remaining code goes here | |
| CLRF STATUS | |
| CLRF PORTB | |
| BSF STATUS, RP0 | |
| MOVLW 0X00 | |
| MOVWF TRISB | |
| CLRF STATUS | |
| init: | |
| bcf STATUS , C | |
| MOVLW 0X07 | |
| MOVWF contador | |
| CALL sub_delay | |
| MOVLW 0X01 | |
| MOVWF var5 | |
| movf var5,w | |
| movwf PORTB | |
| rotar: | |
| CALL sub_delay | |
| RLF var5 , f | |
| movf var5,w | |
| movwf PORTB | |
| DECFSZ contador, f | |
| GOTO rotar | |
| GOTO init | |
| sub_delay: | |
| MOVLW 0X04 | |
| MOVWF VAR3 | |
| MOVLW 0XCD | |
| MOVWF VAR2 | |
| MOVLW 0XFF | |
| MOVWF VAR1 | |
| del: | |
| nop | |
| DECFSZ VAR1 , F | |
| GOTO del | |
| DECFSZ VAR2 , F | |
| GOTO del | |
| DECFSZ VAR3 , F | |
| GOTO del | |
| RETURN | |
| END ; directive 'end of program' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment