Pwm Assembler

Páginas: 5 (1216 palabras) Publicado: 27 de abril de 2012
;**********************************************************************
; 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 MPASMUser'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 ; 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
w_temp EQU 0x7D ; variable used for context saving
status_temp EQU0x7E ; 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 locationmovwf 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

movfpclath_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...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Assembler
  • Assembler
  • Assembler
  • assembler
  • PWM
  • Pwm
  • que es pwm
  • Intrupciones Assembler

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS