Electronic Sixth Sense Resources Home
AQA Syllabus 1-9
Safety
Monostables
Astables
Basic Calculation Q1
Basic Calculation Q2
555 Astable Oscillation
555 Monostable Multivibrator
Operational Amplifier
Inverting Amplifiers
Activities
Glossary
Recognition
Microcontrollers and PICs Introduction
The PIC Chip
Programming Section A
Programming Section B
Programming Section C
Programming Section D
Useful Websites
Text Only Version
SixthSense banner
Interactive learning resources for GCSE and A-Level
Art
Biology
Business Studies
Chemistry
Citizenship
Electronics
English Language
English Literature
GCSE Applied Science
GCSE Leisure and Tourism
GCSE Travel and Tourism
Geography
Health & Social Care
History
ICT
Mathematics
French
German
Spanish
Physics
PE
Psychology
Sociology
art
Biology
Business Studies
Chemistry
Citizenship
Electronics
English Language
English Literature
GCSE Applied Science
GCSE Leisure Tourism
GCSE Travel Tourism
Geography
Health and Social Care
History
ICT
Law
Maths
Modern Languages
French
German
Spanish
PE
Physics
Psychology
Sociology



Programming Section A: The Template Program
Each template program conforms to the structure opposite.
Each line then following the same format:-

;*************************************************************************************************************
;  
TITLE: New 16F84
   
;
AUTHOR:
 
DATE:
 
;*************************************************************************************************************
;State here what the program does
;*************************************************************************************************************
; DEFINITIONS
;*************************************************************************************************************
list P=PIC16C84, R=D ;Define PIC type and radix (H=Hex, D=Decimal).
include "P16C84.INC" ;P16C84.INC is a file containing definitions of PIC ;registers
;****** REGISTER USAGE ******  
  ;For PIC16C84, user RAM starts at 0Ch.
temp1
equ 0Ch ;Temporary register 1
temp2 equ 0Dh ;Temporary register 2
count equ 0Eh ;Counter register
;*************************************************************************************************************
;
VECTORS
;*************************************************************************************************************
  ;The PIC16C84 vectors live at the bottom of memory (0000h-0007h)
org 0000h   ;Reset vector for PIC16C84 is at 0000h
  goto start ;Go to main program start
org 0004h   ;Interrupt vector for PIC16C84 is at 0004h
  goto inter ;Go to start of interrupt service routine
org 0008h   ;First location available to programs
;*************************************************************************************************************
; SUBROUTINES
;*************************************************************************************************************
; Subroutines are placed after the vectors at the bottom of memory so that small programs run faster.
;Code for subroutines goes here
;*************************************************************************************************************
; MAIN PROGRAM
;*************************************************************************************************************
;******INITIALISATION ******  
;Before using the I/O ports, data direction registers must be set up. A '1' in these registers sets the ;corresponding port
;line to an input, and a '0' makes the corresponding line an output.
 
start bsf STATUS,RP0 ;Select special register set
  movlw b'11111' ;Set port A data direction to 'all I/P'
  movwf TRISA  
  movlw b'00000000' ;Set port B data direction to 'all O/P'
  movwf TRISB  
  bcf STATUS,RP0 ;Select normal register set
 
;****** MAIN PROGRAM ******  
;The code for the main program goes here
;*************************************************************************************************************
; INTERRUPT SERVICE ROUTINE  
;*************************************************************************************************************
  ;The interrupt service routine (if required) goes here
inter  
  END   ;All programs must end with this


OSFC disclaimer banner