





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The Assembler Programming and Computer Organization, is very helpful series of lecture slides, which made programming an easy task. The major points in these laboratory assignment are:Determine Frequency, Development Board, Write Code, Hardware Specification, Assembly Instructions, Frequency of Oscillator, Oscillator Description, Interrupt Handler, Debug Board, Timer for Rotation
Typology: Slides
1 / 9
This page cannot be seen from the preview
Don't miss anything!






The Lab - Overview
Task 2: Write your own Interrupt Handler
In the previous lab, you’ve seen a number of programs that employ the
switch, the interrupt handler, the timer for rotation, etc. Your goal in this Task is to use these components in a new way. Here’s what your program Task2.asm should do.
Using the Debug Board, the switch must cause an interrupt. The switch
toggles between two LED actions – an “all flash” mode in which all four LEDs are alternately on/off and a “rotate” mode similar to that in 03_Rotate.asm. The Pot does not need to be used unless you wish to. The frequency of flash/rotate can be constant.
You can wire the switch to any pin on the PIC that you wish.
.
Task 2: Write your own Interrupt Handler
Task 3: Write an EEPROM Reader/Writer
The code given in the 16F886 spec doesn’t really work. Here’s some modified code that seems OK.
#define XX ; Your choice of locations ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; This code is modified from that in the 16F886 Manual, Section 10.1. ; Enter: ; You must previoiusly have a #define that specifies the EEProm ; address where the data should be written. Here it's written ; as DATA_EE_ADDR ; Exit: ; W contains the value read from EEProm ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; EEProm_Read: BANKSEL EEADR ; movlw DATA_EE_ADDR ; Address we're using in EEProm movwf EEADR ; Data Memory Address to read BANKSEL EECON1 ; bcf EECON1, EEPGD ; Specify using EEProm data memory bsf EECON1, RD ; Set RD bit to begin reading BANKSEL EEDAT movf EEDAT, W ; W = EEDAT BANKSEL STATUS ; Bank 0 return
Task 3: Write an EEPROM Reader/Writer
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; This code is modified from that in the 16F886 Manual, Section 10.1. ; Enter: ; On entry, W contains the value to be written ; You must previoiusly have a #define that specifies the EEProm ; address where the data should be written. ; Exit: ; No values are returned. Bank is restored to 0. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; EEProm_Write: BANKSEL EEADR ; movwf EEDATA ; Data Memory Value to write movlw DATA_EE_ADDR movwf EEADR ; Data Memory Address to write BANKSEL EECON bcf EECON1, EEPGD ; Specify using EEProm data memory bsf EECON1, WREN ; Enable writes movlw 55h ; Simply because the formula says to do this movwf EECON2 ; Write 55h to virtual address movlw 0xAA ; movwf EECON2 ; Write AAh bsf EECON1, WR ;Set WR bit to begin write EEProm_Loop: btfsc EECON1, WR ; When bit is clear, write has finished goto EEProm_Loop bcf EECON1, WREN ;Disable writes BANKSEL 0x00 ;Bank 0 -return to normal return Docsity.com