PICkit ? 1 Flash Starter Kit User’s Guide
C.7
LESSON 5 – PROGRAM MEMORY LOOK-UP ROUTINES
There is often a need to store constants or strings in a PIC microcontroller. Storing this
information in program memory is the best solution as long as this data never needs to
change and program memory is available. Program memory is non-volatile, therefore,
it will maintain information regardless of V DD voltage levels or PIC microcontroller reset.
This lesson demonstrates how to retrieve data from Program Memory. It covers the
following topics:
? What a program memory look-up table is
? How a program memory look-up table is implemented
? Why a program memory look-up table is useful
C.7.1
Design
Constants stored in program memory are accessed via look-up tables. A look-up table
is similar to a computed goto (see Lesson 2 ) only instead of a list of goto statements,
after incrementing the program counter, there is a list of retlw instructions. Each
retlw instruction is followed by one byte of the information. Example C-3 shows a
look-up table for the string “Microchip” written in assembly language.
EXAMPLE C-3:
LOOK-UP TABLE WRITTEN IN ASSEMBLY
LookupProgramMemory
movlw high StartTable
movwf PCLATH
movlw low StartTable
addwf index, w
btfsc STATUS, C
incf PCLATH, f
movwf PCL
StartTable
retlw
retlw
retlw
retlw
retlw
retlw
retlw
retlw
retlw
" M "
" i "
"c"
"r"
"o"
"c"
"h"
"i"
"p"
For this lesson, constants corresponding to a sequence of LEDs are stored in a
program memory look-up table. For instance, the first constant stored is 5F. This
corresponds to the binary number “ 01011111 ”. Each bit corresponds to an LED,
therefore, LEDs D0, D1, D2, D3, D4 and D6 will be lit when this constant is accessed.
After each look-up table, the value is displayed on the LEDs in the same fashion as
discussed in Lesson 3 , using the Timer0 interrupt. The appearance of more than one
LED being lit at a time is possible because the LEDs are multiplexed fast enough that
the human eye can not detect the LEDs being turned on and off. When SW1 is pressed,
an interrupt-on-change is generated to increment the lookup to the next location.
Figure C-14 shows the flowchart for this example.
DS40051D-page 60
? 2004 Microchip Technology Inc.
相关PDF资料
DV164120 KIT STARTER PICKIT 2
DV164121 KIT PICKIT 2 DEBUG EXPRESS
DV164122 ANALYZER SRL PICKIT W/DEMO BOARD
DV164131 KIT STARTER PICKIT 3
DV164132 KIT EVAL F1 FOR PIC12F1/PIC16F1
DV243003 KIT STARTER FOR SRL MEM PRODUCTS
DVA1001 ADAPTER FOR PIC16F716 18DIP
DVA1004 DEVICE ADAPTER 8/14/20DIP
相关代理商/技术参数
DV164101 制造商:Microchip Technology Inc 功能描述:TOOLS: FLASH MICROCONTROLLER (
DV164102 功能描述:开发板和工具包 - 无线 rfPICkit RoHS:否 制造商:Arduino 产品:Evaluation Boards 工具用于评估:AT32UC3L 核心:AVR32 频率: 接口类型:USB 工作电源电压:5 V
DV164120 功能描述:电路内置调试器 PICkit 2 8/14/20P Flash RoHS:否 制造商:Microchip Technology 产品:In-Circuit Debugger Kits 工具用于评估:PIC MCUs, dsPIC DSCs 用于:07-00024, AC164113 核心:dsPIC, PIC 接口类型:USB 工作电源电压:3 V to 5 V
DV164121 功能描述:电路内置调试器 PICkit 2 Debug Express RoHS:否 制造商:Microchip Technology 产品:In-Circuit Debugger Kits 工具用于评估:PIC MCUs, dsPIC DSCs 用于:07-00024, AC164113 核心:dsPIC, PIC 接口类型:USB 工作电源电压:3 V to 5 V
DV164121 制造商:Microchip Technology Inc 功能描述:ICPICKIT2 PROGRAMMER/DEBUGGER ((NW))
DV164121+TEFLCST3 制造商:Microchip Technology Inc 功能描述:KIT PICKIT2+FLOWCODE-HOME BUNDLE 制造商:Microchip Technology Inc 功能描述:ICD, PICKIT 2, FLOW CODE, PIC, DSPIC 制造商:Microchip Technology Inc 功能描述:ICD, PICKIT 2, DEBUG EXP, FLOW CODE, PIC, DSPIC; Silicon Family Name:PIC12F6xx, PIC16F5xx; Core Architecture:PIC; Core Sub-Architecture:PIC12, PIC18, PIC24; IC Product Type:Debugger / Programmer; Series:PICkit 2 ;RoHS Compliant: Yes
DV164122 功能描述:界面开发工具 PICkit Ser Analyzer RoHS:否 制造商:Bourns 产品:Evaluation Boards 类型:RS-485 工具用于评估:ADM3485E 接口类型:RS-485 工作电源电压:3.3 V
DV164126 功能描述:开发板和工具包 - PIC / DSPIC USB Kit w/ PICkit LowPinCount RoHS:否 制造商:Microchip Technology 产品:Starter Kits 工具用于评估:chipKIT 核心:Uno32 接口类型: 工作电源电压: