0% found this document useful (0 votes)
168 views2 pages

PIC16F684 Assembly Code Template

This document contains an assembly code template for the PIC16F684 microcontroller. It includes basic code blocks and directives for building programs, and notes on configuration words and required files. Interrupt handling code is provided to save and restore registers. The template also defines variables and EEPROM locations for data storage.

Uploaded by

houssin ait alè
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
168 views2 pages

PIC16F684 Assembly Code Template

This document contains an assembly code template for the PIC16F684 microcontroller. It includes basic code blocks and directives for building programs, and notes on configuration words and required files. Interrupt handling code is provided to save and restore registers. The template also defines variables and EEPROM locations for data storage.

Uploaded by

houssin ait alè
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

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

; This file is a basic code template for assembly code generation *


; on the PIC16F684. 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: P16F684.INC *
; *
;**********************************************************************
; *
; Notes: *
; *
;**********************************************************************

list p=16f684 ; list directive to define processor


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

__CONFIG _CP_OFF & _CPD_OFF & _BOD_OFF & _PWRTE_ON & _WDT_OFF &
_INTRC_OSC_NOCLKOUT & _MCLRE_ON & _FCMEN_OFF & _IESO_OFF

; '__CONFIG' directive is used to embed configuration data within .asm file.


; The labels 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 0x7E ; variable used for context saving
status_temp EQU 0x7F ; variable used for context saving

;**********************************************************************
ORG 0x000 ; processor reset vector
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

; isr code can go here or be located as a call subroutine elsewhere

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

ORG 0x2100 ; data EEPROM location


DE 1,2,3,4 ; define first four EEPROM locations as
1, 2, 3, and 4

END ; directive 'end of program'

You might also like