1 |
4 |
mezzah |
--------------------------------------------------------------------------------
|
2 |
|
|
-- Company: Ferhat Abbas University - Algeria
|
3 |
|
|
-- Engineer: Ibrahim MEZZAH
|
4 |
|
|
-- Progect Supervisor: Dr H. Chemali
|
5 |
|
|
-- Create Date: 07:59:40 05/24/05
|
6 |
|
|
-- Design Name: Program memory
|
7 |
|
|
-- Module Name: Program_Memory - ROM
|
8 |
|
|
-- Project Name: MCIP open
|
9 |
|
|
-- Target Device: xc3s500e-4fg320
|
10 |
|
|
-- Tool versions: Xilinx ISE 9.1.03i
|
11 |
|
|
-- Description: Contains the MCIP program. The instruction is encoded on 2 bytes.
|
12 |
|
|
-- The size is generic (Rom_size), the max is 2MB.
|
13 |
|
|
-- Revision: 07/07/2008
|
14 |
|
|
-- Revision 1 - Add description
|
15 |
|
|
-- Additional Comments:
|
16 |
|
|
--------------------------------------------------------------------------------
|
17 |
|
|
library IEEE;
|
18 |
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
19 |
|
|
use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
20 |
|
|
use IEEE.NUMERIC_STD.all;
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
entity Program_Memory is
|
24 |
|
|
Generic (IAlength : integer := 14); -- Instruction Address Length -- min = 2, max = 21
|
25 |
|
|
Port ( Address : in std_logic_vector(IALength-1 downto 0);
|
26 |
|
|
nreset : in std_logic;
|
27 |
|
|
Q1 : in std_logic;
|
28 |
|
|
Instruction : out std_logic_vector(15 downto 0));
|
29 |
|
|
end Program_Memory;
|
30 |
|
|
|
31 |
|
|
architecture ROM of Program_Memory is
|
32 |
|
|
|
33 |
|
|
constant Rom_size : integer := 2**(IALength);
|
34 |
|
|
|
35 |
|
|
type Rom_Table is array(0 to (Rom_size-1)) of std_logic_vector(7 downto 0);
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
constant ROM : Rom_Table :=
|
40 |
|
|
|
41 |
|
|
(
|
42 |
|
|
X"02",X"EF",X"00",X"F0",X"0F",X"0E",X"94",X"6E",X"8C",X"6A",X"1F",X"0E",X"95",X"6E",X"0F",X"0E",
|
43 |
|
|
X"89",X"6A",X"92",X"6E",X"93",X"6A",X"30",X"0E",X"8B",X"6E",X"8C",X"8E",X"00",X"00",X"00",X"00",
|
44 |
|
|
X"8C",X"9E",X"EB",X"EC",X"00",X"F0",X"EB",X"EC",X"00",X"F0",X"8C",X"8E",X"00",X"00",X"00",X"00",
|
45 |
|
|
X"8C",X"9E",X"DA",X"EC",X"00",X"F0",X"DA",X"EC",X"00",X"F0",X"8C",X"8E",X"00",X"00",X"00",X"00",
|
46 |
|
|
X"8C",X"9E",X"DA",X"EC",X"00",X"F0",X"DA",X"EC",X"00",X"F0",X"20",X"0E",X"8B",X"6E",X"8C",X"8E",
|
47 |
|
|
X"00",X"00",X"00",X"00",X"8C",X"9E",X"DA",X"EC",X"00",X"F0",X"DA",X"EC",X"00",X"F0",X"28",X"0E",
|
48 |
|
|
X"0D",X"6E",X"11",X"EC",X"01",X"F0",X"DA",X"EC",X"00",X"F0",X"DA",X"EC",X"00",X"F0",X"08",X"0E",
|
49 |
|
|
X"0D",X"6E",X"11",X"EC",X"01",X"F0",X"DA",X"EC",X"00",X"F0",X"DA",X"EC",X"00",X"F0",X"0C",X"0E",
|
50 |
|
|
X"0D",X"6E",X"11",X"EC",X"01",X"F0",X"DA",X"EC",X"00",X"F0",X"DA",X"EC",X"00",X"F0",X"06",X"0E",
|
51 |
|
|
X"0D",X"6E",X"11",X"EC",X"01",X"F0",X"DA",X"EC",X"00",X"F0",X"DA",X"EC",X"00",X"F0",X"01",X"0E",
|
52 |
|
|
X"0D",X"6E",X"11",X"EC",X"01",X"F0",X"EB",X"EC",X"00",X"F0",X"EB",X"EC",X"00",X"F0",X"03",X"0E",
|
53 |
|
|
X"0E",X"6E",X"5D",X"EC",X"01",X"F0",X"DA",X"EC",X"00",X"F0",X"48",X"0E",X"0E",X"6E",X"36",X"EC",
|
54 |
|
|
X"01",X"F0",X"DA",X"EC",X"00",X"F0",X"65",X"0E",X"0E",X"6E",X"36",X"EC",X"01",X"F0",X"DA",X"EC",
|
55 |
|
|
X"00",X"F0",X"6C",X"0E",X"0E",X"6E",X"36",X"EC",X"01",X"F0",X"DA",X"EC",X"00",X"F0",X"6C",X"0E",
|
56 |
|
|
X"0E",X"6E",X"36",X"EC",X"01",X"F0",X"DA",X"EC",X"00",X"F0",X"6F",X"0E",X"0E",X"6E",X"36",X"EC",
|
57 |
|
|
X"01",X"F0",X"DA",X"EC",X"00",X"F0",X"20",X"0E",X"0E",X"6E",X"36",X"EC",X"01",X"F0",X"DA",X"EC",
|
58 |
|
|
X"00",X"F0",X"4D",X"0E",X"0E",X"6E",X"36",X"EC",X"01",X"F0",X"DA",X"EC",X"00",X"F0",X"43",X"0E",
|
59 |
|
|
X"0E",X"6E",X"36",X"EC",X"01",X"F0",X"DA",X"EC",X"00",X"F0",X"49",X"0E",X"0E",X"6E",X"36",X"EC",
|
60 |
|
|
X"01",X"F0",X"DA",X"EC",X"00",X"F0",X"50",X"0E",X"0E",X"6E",X"36",X"EC",X"01",X"F0",X"DA",X"EC",
|
61 |
|
|
X"00",X"F0",X"21",X"0E",X"0E",X"6E",X"36",X"EC",X"01",X"F0",X"DA",X"EC",X"00",X"F0",X"53",X"0E",
|
62 |
|
|
X"0E",X"6E",X"5D",X"EC",X"01",X"F0",X"DA",X"EC",X"00",X"F0",X"3C",X"0E",X"0E",X"6E",X"36",X"EC",
|
63 |
|
|
X"01",X"F0",X"DA",X"EC",X"00",X"F0",X"3C",X"0E",X"0E",X"6E",X"36",X"EC",X"01",X"F0",X"DA",X"EC",
|
64 |
|
|
X"00",X"F0",X"63",X"0E",X"0E",X"6E",X"5D",X"EC",X"01",X"F0",X"DA",X"EC",X"00",X"F0",X"3C",X"0E",
|
65 |
|
|
X"0E",X"6E",X"36",X"EC",X"01",X"F0",X"DA",X"EC",X"00",X"F0",X"3C",X"0E",X"0E",X"6E",X"36",X"EC",
|
66 |
|
|
X"01",X"F0",X"DA",X"EC",X"00",X"F0",X"22",X"0E",X"0C",X"6E",X"FE",X"EC",X"00",X"F0",X"0C",X"2E",
|
67 |
|
|
X"FC",X"D7",X"80",X"0E",X"8A",X"6E",X"8A",X"46",X"18",X"0E",X"0D",X"6E",X"11",X"EC",X"01",X"F0",
|
68 |
|
|
X"0F",X"0E",X"80",X"14",X"0C",X"6E",X"0C",X"2A",X"FE",X"EC",X"00",X"F0",X"0C",X"06",X"0C",X"66",
|
69 |
|
|
X"FB",X"D7",X"F1",X"D7",X"D8",X"CF",X"81",X"F0",X"E8",X"CF",X"80",X"F0",X"E0",X"CF",X"82",X"F0",
|
70 |
|
|
X"AC",X"0E",X"09",X"6E",X"09",X"3E",X"FE",X"D7",X"82",X"C0",X"E0",X"FF",X"80",X"C0",X"E8",X"FF",
|
71 |
|
|
X"81",X"C0",X"D8",X"FF",X"12",X"00",X"D8",X"CF",X"84",X"F0",X"E8",X"CF",X"83",X"F0",X"E0",X"CF",
|
72 |
|
|
X"85",X"F0",X"25",X"0E",X"0A",X"6E",X"DA",X"EC",X"00",X"F0",X"0A",X"2E",X"FC",X"D7",X"85",X"C0",
|
73 |
|
|
X"E0",X"FF",X"83",X"C0",X"E8",X"FF",X"84",X"C0",X"D8",X"FF",X"12",X"00",X"D8",X"CF",X"87",X"F0",
|
74 |
|
|
X"E8",X"CF",X"86",X"F0",X"E0",X"CF",X"88",X"F0",X"24",X"0E",X"0B",X"6E",X"EB",X"EC",X"00",X"F0",
|
75 |
|
|
X"0B",X"2E",X"FC",X"D7",X"88",X"C0",X"E0",X"FF",X"86",X"C0",X"E8",X"FF",X"87",X"C0",X"D8",X"FF",
|
76 |
|
|
X"12",X"00",X"D8",X"CF",X"8A",X"F0",X"E8",X"CF",X"89",X"F0",X"E0",X"CF",X"8B",X"F0",X"0D",X"C0",
|
77 |
|
|
X"8B",X"FF",X"8C",X"8E",X"00",X"00",X"00",X"00",X"00",X"00",X"8C",X"9E",X"8B",X"3A",X"00",X"00",
|
78 |
|
|
X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",
|
79 |
|
|
X"00",X"00",X"00",X"00",X"8C",X"8E",X"00",X"00",X"00",X"00",X"00",X"00",X"8C",X"9E",X"8B",X"C0",
|
80 |
|
|
X"E0",X"FF",X"89",X"C0",X"E8",X"FF",X"8A",X"C0",X"D8",X"FF",X"12",X"00",X"D8",X"CF",X"8A",X"F0",
|
81 |
|
|
X"E8",X"CF",X"89",X"F0",X"E0",X"CF",X"8B",X"F0",X"0E",X"C0",X"8B",X"FF",X"8C",X"8C",X"8C",X"8E",
|
82 |
|
|
X"00",X"00",X"00",X"00",X"00",X"00",X"8C",X"9E",X"8B",X"3A",X"00",X"00",X"00",X"00",X"00",X"00",
|
83 |
|
|
X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",
|
84 |
|
|
X"8C",X"8E",X"00",X"00",X"00",X"00",X"00",X"00",X"8C",X"9E",X"8C",X"9C",X"8B",X"C0",X"E0",X"FF",
|
85 |
|
|
X"89",X"C0",X"E8",X"FF",X"8A",X"C0",X"D8",X"FF",X"12",X"00",X"D8",X"CF",X"8A",X"F0",X"E8",X"CF",
|
86 |
|
|
X"89",X"F0",X"E0",X"CF",X"8B",X"F0",X"80",X"0E",X"0E",X"12",X"0E",X"C0",X"8B",X"FF",X"8C",X"8E",
|
87 |
|
|
X"00",X"00",X"00",X"00",X"00",X"00",X"8C",X"9E",X"8B",X"3A",X"00",X"00",X"00",X"00",X"00",X"00",
|
88 |
|
|
X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",X"00",
|
89 |
|
|
X"8C",X"8E",X"00",X"00",X"00",X"00",X"00",X"00",X"8C",X"9E",X"8B",X"C0",X"E0",X"FF",X"89",X"C0",
|
90 |
|
|
X"E8",X"FF",X"8A",X"C0",X"D8",X"FF",X"12",X"00",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",X"FF",
|
91 |
|
|
others => X"FF" );
|
92 |
|
|
|
93 |
|
|
-- teh original HEX file --------------------
|
94 |
|
|
--:1000000002EF00F00F0E946E8C6A1F0E956E0F0EAD
|
95 |
|
|
--:10001000896A926E936A300E8B6E8C8E000000009F
|
96 |
|
|
--:100020008C9EEBEC00F0EBEC00F08C8E00000000FE
|
97 |
|
|
--:100030008C9EDAEC00F0DAEC00F08C8E0000000010
|
98 |
|
|
--:100040008C9EDAEC00F0DAEC00F0200E8B6E8C8ED9
|
99 |
|
|
--:10005000000000008C9EDAEC00F0DAEC00F0280ED4
|
100 |
|
|
--:100060000D6E11EC01F0DAEC00F0DAEC00F0080EA5
|
101 |
|
|
--:100070000D6E11EC01F0DAEC00F0DAEC00F00C0E91
|
102 |
|
|
--:100080000D6E11EC01F0DAEC00F0DAEC00F0060E87
|
103 |
|
|
--:100090000D6E11EC01F0DAEC00F0DAEC00F0010E7C
|
104 |
|
|
--:1000A0000D6E11EC01F0EBEC00F0EBEC00F0030E48
|
105 |
|
|
--:1000B0000E6E5DEC01F0DAEC00F0480E0E6E36ECE0
|
106 |
|
|
--:1000C00001F0DAEC00F0650E0E6E36EC01F0DAECC1
|
107 |
|
|
--:1000D00000F06C0E0E6E36EC01F0DAEC00F06C0EF7
|
108 |
|
|
--:1000E0000E6E36EC01F0DAEC00F06F0E0E6E36ECB0
|
109 |
|
|
--:1000F00001F0DAEC00F0200E0E6E36EC01F0DAECD6
|
110 |
|
|
--:1001000000F04D0E0E6E36EC01F0DAEC00F0430E0E
|
111 |
|
|
--:100110000E6E36EC01F0DAEC00F0490E0E6E36ECA5
|
112 |
|
|
--:1001200001F0DAEC00F0500E0E6E36EC01F0DAEC75
|
113 |
|
|
--:1001300000F0210E0E6E36EC01F0DAEC00F0530EFA
|
114 |
|
|
--:100140000E6E5DEC01F0DAEC00F03C0E0E6E36EC5B
|
115 |
|
|
--:1001500001F0DAEC00F03C0E0E6E36EC01F0DAEC59
|
116 |
|
|
--:1001600000F0630E0E6E5DEC01F0DAEC00F03C0E78
|
117 |
|
|
--:100170000E6E36EC01F0DAEC00F03C0E0E6E36EC52
|
118 |
|
|
--:1001800001F0DAEC00F0220E0C6EFEEC00F00C2E0A
|
119 |
|
|
--:10019000FCD7800E8A6E8A46180E0D6E11EC01F0A7
|
120 |
|
|
--:1001A0000F0E80140C6E0C2AFEEC00F00C060C6690
|
121 |
|
|
--:1001B000FBD7F1D7D8CF81F0E8CF80F0E0CF82F045
|
122 |
|
|
--:1001C000AC0E096E093EFED782C0E0FF80C0E8FF9A
|
123 |
|
|
--:1001D00081C0D8FF1200D8CF84F0E8CF83F0E0CF01
|
124 |
|
|
--:1001E00085F0250E0A6EDAEC00F00A2EFCD785C0E9
|
125 |
|
|
--:1001F000E0FF83C0E8FF84C0D8FF1200D8CF87F0AB
|
126 |
|
|
--:10020000E8CF86F0E0CF88F0240E0B6EEBEC00F028
|
127 |
|
|
--:100210000B2EFCD788C0E0FF86C0E8FF87C0D8FF60
|
128 |
|
|
--:100220001200D8CF8AF0E8CF89F0E0CF8BF00DC074
|
129 |
|
|
--:100230008BFF8C8E0000000000008C9E8B3A00002B
|
130 |
|
|
--:1002400000000000000000000000000000000000AE
|
131 |
|
|
--:10025000000000008C8E0000000000008C9E8BC00F
|
132 |
|
|
--:10026000E0FF89C0E8FF8AC0D8FF1200D8CF8AF02B
|
133 |
|
|
--:10027000E8CF89F0E0CF8BF00EC08BFF8C8C8C8E9A
|
134 |
|
|
--:100280000000000000008C9E8B3A0000000000007F
|
135 |
|
|
--:10029000000000000000000000000000000000005E
|
136 |
|
|
--:1002A0008C8E0000000000008C9E8C9C8BC0E0FFB8
|
137 |
|
|
--:1002B00089C0E8FF8AC0D8FF1200D8CF8AF0E8CF03
|
138 |
|
|
--:1002C00089F0E0CF8BF0800E0E120EC08BFF8C8E6B
|
139 |
|
|
--:1002D0000000000000008C9E8B3A0000000000002F
|
140 |
|
|
--:1002E000000000000000000000000000000000000E
|
141 |
|
|
--:1002F0008C8E0000000000008C9E8BC0E0FF89C047
|
142 |
|
|
--:10030000E8FF8AC0D8FF1200FFFFFFFFFFFFFFFFDB
|
143 |
|
|
---end---------------------------------------
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
|
147 |
|
|
begin
|
148 |
|
|
process(nreset, Q1)
|
149 |
|
|
begin
|
150 |
|
|
if nreset = '0' then
|
151 |
|
|
Instruction <= (others => '0');
|
152 |
|
|
else
|
153 |
|
|
if Q1'event and Q1 = '0' then
|
154 |
|
|
Instruction <= ROM( CONV_INTEGER( Address(IALength-1 downto 0) + 1 ) )
|
155 |
|
|
& ROM( CONV_INTEGER( Address(IALength-1 downto 0) ) );
|
156 |
|
|
end if;
|
157 |
|
|
end if;
|
158 |
|
|
end process;
|
159 |
|
|
end ROM;
|
160 |
|
|
|
161 |
|
|
|
162 |
|
|
--///////////////////////////////////////////////////////////////////////////////
|
163 |
|
|
-- THE ORIGINAL PROGRAM, DEVELOPED ON MPLAP IDE v8.83 (ASM CODE)
|
164 |
|
|
--;******************************************************************************
|
165 |
|
|
--; *
|
166 |
|
|
--; Filename: Hi_MCIPopen.asm *
|
167 |
|
|
--; Description: ASM program for MCIPopen implementation example *
|
168 |
|
|
--; Date: 07/25/2015 *
|
169 |
|
|
--; File Version: 1 *
|
170 |
|
|
--; *
|
171 |
|
|
--; Author: Ibrahim MEZZAH *
|
172 |
|
|
--; Company: Ferhat Abbas University - Algeria *
|
173 |
|
|
--; *
|
174 |
|
|
--;******************************************************************************
|
175 |
|
|
--; *
|
176 |
|
|
--; Files Required: P18F4410.INC *
|
177 |
|
|
--; *
|
178 |
|
|
--;******************************************************************************
|
179 |
|
|
--
|
180 |
|
|
-- LIST P=18F4410 ;directive to define processor
|
181 |
|
|
-- #include <P18F4410.INC> ;processor specific variable definitions
|
182 |
|
|
--
|
183 |
|
|
--
|
184 |
|
|
--
|
185 |
|
|
--; Oscillator Selection:
|
186 |
|
|
-- CONFIG OSC = LP ;LP
|
187 |
|
|
--
|
188 |
|
|
--
|
189 |
|
|
--
|
190 |
|
|
--; LCD defines /////////////////////////////////////////
|
191 |
|
|
--#define LCD_DATA_PRT 0xF8B ;/*PRTC*/
|
192 |
|
|
--#define LCD_DATA_PORT 0x8B
|
193 |
|
|
--#define LCD_TRIS_DATA_PORT 0x94
|
194 |
|
|
--#define LCD_INST_PORT 0x8C ;/*PRTD*/
|
195 |
|
|
--#define LCD_TRIS_INST_PORT 0x95
|
196 |
|
|
--
|
197 |
|
|
--#define RW_PIN 5 ;/* PORT for RW */
|
198 |
|
|
--#define RS_PIN 6 ;/* PORT for RS */
|
199 |
|
|
--#define E_PIN 7 ;/* PORT for E */
|
200 |
|
|
--
|
201 |
|
|
--#define FOUR_BIT 0x28 ;0b00101000
|
202 |
|
|
--#define CLEAR 0x01 ;0b00000001
|
203 |
|
|
--#define CURSOR_HOME 0x02 ;0b00000010
|
204 |
|
|
--#define MODE_SET 0x06 ;0b00000110
|
205 |
|
|
--#define DISPLAY_ON_C 0x0e ;0b00001110
|
206 |
|
|
--#define DISPLAY_ON_B 0x0f ;0b00001111
|
207 |
|
|
--#define DISPLAY_ON 0x0c ;0b00001100
|
208 |
|
|
--#define DISPLAY_OFF 0x08 ;0b00001000
|
209 |
|
|
--#define SHIFT_D_R 0x1c ;0b00011100
|
210 |
|
|
--#define SHIFT_D_L 0x18 ;0b00011000
|
211 |
|
|
--#define SHIFT_C_R 0x14 ;0b00010100
|
212 |
|
|
--#define SHIFT_C_L 0x10 ;0b00010000
|
213 |
|
|
--
|
214 |
|
|
--#define access 0
|
215 |
|
|
--
|
216 |
|
|
-- CBLOCK 0x080
|
217 |
|
|
-- WREG_TEMP1 ;variable used for context saving
|
218 |
|
|
-- STATUS_TEMP1 ;variable used for context saving
|
219 |
|
|
-- BSR_TEMP1 ;variable used for context saving
|
220 |
|
|
--
|
221 |
|
|
-- WREG_TEMP2 ;variable used for context saving
|
222 |
|
|
-- STATUS_TEMP2 ;variable used for context saving
|
223 |
|
|
-- BSR_TEMP2 ;variable used for context saving
|
224 |
|
|
--
|
225 |
|
|
-- WREG_TEMP3 ;variable used for context saving
|
226 |
|
|
-- STATUS_TEMP3 ;variable used for context saving
|
227 |
|
|
-- BSR_TEMP3 ;variable used for context saving
|
228 |
|
|
--
|
229 |
|
|
-- WREG_TEMP4 ;variable used for context saving
|
230 |
|
|
-- STATUS_TEMP4 ;variable used for context saving
|
231 |
|
|
-- BSR_TEMP4 ;variable used for context saving
|
232 |
|
|
-- ENDC
|
233 |
|
|
--
|
234 |
|
|
-- CBLOCK 0x009 ;variables in access RAM
|
235 |
|
|
-- e1
|
236 |
|
|
-- e2
|
237 |
|
|
-- e3
|
238 |
|
|
-- e4
|
239 |
|
|
-- LCD_command
|
240 |
|
|
-- LCD_data
|
241 |
|
|
-- ENDC
|
242 |
|
|
--
|
243 |
|
|
--
|
244 |
|
|
--;******************************************************************************
|
245 |
|
|
--;Reset vector
|
246 |
|
|
--; This code will start executing when a reset occurs.
|
247 |
|
|
--
|
248 |
|
|
-- ORG 0x0000
|
249 |
|
|
--
|
250 |
|
|
-- goto Main ;go to start of main code
|
251 |
|
|
--
|
252 |
|
|
--
|
253 |
|
|
--
|
254 |
|
|
--Main:
|
255 |
|
|
--
|
256 |
|
|
-- ;------------------------------------------------------------------------------
|
257 |
|
|
-- ; I/O ports configuration
|
258 |
|
|
-- ;------------------------------------------------------------------------------
|
259 |
|
|
--
|
260 |
|
|
-- MOVLW 0x0f
|
261 |
|
|
-- MOVWF LCD_TRIS_DATA_PORT,0
|
262 |
|
|
-- CLRF LCD_INST_PORT,0
|
263 |
|
|
-- MOVLW 0x1f
|
264 |
|
|
-- MOVWF LCD_TRIS_INST_PORT,0
|
265 |
|
|
--
|
266 |
|
|
-- MOVLW 0x0f
|
267 |
|
|
-- CLRF LATA
|
268 |
|
|
-- MOVWF TRISA
|
269 |
|
|
-- CLRF TRISB
|
270 |
|
|
-- ;------------------------------------------------------------------------------
|
271 |
|
|
-- ; LCD Initialisation
|
272 |
|
|
-- ;------------------------------------------------------------------------------
|
273 |
|
|
--
|
274 |
|
|
--
|
275 |
|
|
-- MOVLW 0x30
|
276 |
|
|
-- MOVWF LCD_DATA_PORT,0
|
277 |
|
|
-- BSF LCD_INST_PORT,E_PIN,0
|
278 |
|
|
-- NOP
|
279 |
|
|
-- NOP
|
280 |
|
|
-- BCF LCD_INST_PORT,E_PIN,0
|
281 |
|
|
--
|
282 |
|
|
-- CALL Delay1_6ms
|
283 |
|
|
-- CALL Delay1_6ms
|
284 |
|
|
--
|
285 |
|
|
-- BSF LCD_INST_PORT,E_PIN,0
|
286 |
|
|
-- NOP
|
287 |
|
|
-- NOP
|
288 |
|
|
-- BCF LCD_INST_PORT,E_PIN,0
|
289 |
|
|
--
|
290 |
|
|
-- CALL Delay42us
|
291 |
|
|
-- CALL Delay42us
|
292 |
|
|
--
|
293 |
|
|
-- BSF LCD_INST_PORT,E_PIN,0
|
294 |
|
|
-- NOP
|
295 |
|
|
-- NOP
|
296 |
|
|
-- BCF LCD_INST_PORT,E_PIN,0
|
297 |
|
|
--
|
298 |
|
|
-- CALL Delay42us
|
299 |
|
|
-- CALL Delay42us
|
300 |
|
|
--
|
301 |
|
|
-- MOVLW 0x20
|
302 |
|
|
-- MOVWF LCD_DATA_PORT,0
|
303 |
|
|
-- BSF LCD_INST_PORT,E_PIN,0
|
304 |
|
|
-- NOP
|
305 |
|
|
-- NOP
|
306 |
|
|
-- BCF LCD_INST_PORT,E_PIN,0
|
307 |
|
|
--
|
308 |
|
|
-- CALL Delay42us
|
309 |
|
|
-- CALL Delay42us
|
310 |
|
|
--
|
311 |
|
|
-- MOVLW FOUR_BIT
|
312 |
|
|
-- MOVWF LCD_command,access
|
313 |
|
|
-- CALL Command
|
314 |
|
|
--
|
315 |
|
|
-- CALL Delay42us
|
316 |
|
|
-- CALL Delay42us
|
317 |
|
|
--
|
318 |
|
|
-- MOVLW DISPLAY_OFF
|
319 |
|
|
-- MOVWF LCD_command,access
|
320 |
|
|
-- CALL Command
|
321 |
|
|
--
|
322 |
|
|
-- CALL Delay42us
|
323 |
|
|
-- CALL Delay42us
|
324 |
|
|
--
|
325 |
|
|
-- MOVLW DISPLAY_ON
|
326 |
|
|
-- MOVWF LCD_command,access
|
327 |
|
|
-- CALL Command
|
328 |
|
|
--
|
329 |
|
|
-- CALL Delay42us
|
330 |
|
|
-- CALL Delay42us
|
331 |
|
|
--
|
332 |
|
|
-- MOVLW MODE_SET
|
333 |
|
|
-- MOVWF LCD_command,access
|
334 |
|
|
-- CALL Command
|
335 |
|
|
--
|
336 |
|
|
-- CALL Delay42us
|
337 |
|
|
-- CALL Delay42us
|
338 |
|
|
--
|
339 |
|
|
-- MOVLW CLEAR
|
340 |
|
|
-- MOVWF LCD_command,access
|
341 |
|
|
-- CALL Command
|
342 |
|
|
--
|
343 |
|
|
-- CALL Delay1_6ms
|
344 |
|
|
-- CALL Delay1_6ms
|
345 |
|
|
--
|
346 |
|
|
-- ;------------------------------------------------------------------------------
|
347 |
|
|
-- ; END LCD Initialisation
|
348 |
|
|
-- ;------------------------------------------------------------------------------
|
349 |
|
|
--
|
350 |
|
|
-- ; Displaying "Hello MCIP!"
|
351 |
|
|
-- MOVLW 0x03
|
352 |
|
|
-- MOVWF LCD_data,access
|
353 |
|
|
-- CALL Set_address
|
354 |
|
|
-- CALL Delay42us
|
355 |
|
|
--
|
356 |
|
|
-- MOVLW 'H'
|
357 |
|
|
-- MOVWF LCD_data,access
|
358 |
|
|
-- CALL Display
|
359 |
|
|
-- CALL Delay42us
|
360 |
|
|
--
|
361 |
|
|
-- MOVLW 'e'
|
362 |
|
|
-- MOVWF LCD_data,access
|
363 |
|
|
-- CALL Display
|
364 |
|
|
-- CALL Delay42us
|
365 |
|
|
--
|
366 |
|
|
-- MOVLW 'l'
|
367 |
|
|
-- MOVWF LCD_data,access
|
368 |
|
|
-- CALL Display
|
369 |
|
|
-- CALL Delay42us
|
370 |
|
|
--
|
371 |
|
|
-- MOVLW 'l'
|
372 |
|
|
-- MOVWF LCD_data,access
|
373 |
|
|
-- CALL Display
|
374 |
|
|
-- CALL Delay42us
|
375 |
|
|
--
|
376 |
|
|
-- MOVLW 'o'
|
377 |
|
|
-- MOVWF LCD_data,access
|
378 |
|
|
-- CALL Display
|
379 |
|
|
-- CALL Delay42us
|
380 |
|
|
--
|
381 |
|
|
-- MOVLW ' '
|
382 |
|
|
-- MOVWF LCD_data,access
|
383 |
|
|
-- CALL Display
|
384 |
|
|
-- CALL Delay42us
|
385 |
|
|
--
|
386 |
|
|
-- MOVLW 'M'
|
387 |
|
|
-- MOVWF LCD_data,access
|
388 |
|
|
-- CALL Display
|
389 |
|
|
-- CALL Delay42us
|
390 |
|
|
--
|
391 |
|
|
-- MOVLW 'C'
|
392 |
|
|
-- MOVWF LCD_data,access
|
393 |
|
|
-- CALL Display
|
394 |
|
|
-- CALL Delay42us
|
395 |
|
|
--
|
396 |
|
|
-- MOVLW 'I'
|
397 |
|
|
-- MOVWF LCD_data,access
|
398 |
|
|
-- CALL Display
|
399 |
|
|
-- CALL Delay42us
|
400 |
|
|
--
|
401 |
|
|
-- MOVLW 'P'
|
402 |
|
|
-- MOVWF LCD_data,access
|
403 |
|
|
-- CALL Display
|
404 |
|
|
-- CALL Delay42us
|
405 |
|
|
--
|
406 |
|
|
-- MOVLW '!'
|
407 |
|
|
-- MOVWF LCD_data,access
|
408 |
|
|
-- CALL Display
|
409 |
|
|
-- CALL Delay42us
|
410 |
|
|
--
|
411 |
|
|
--
|
412 |
|
|
-- ;--------------------
|
413 |
|
|
-- MOVLW 0x53
|
414 |
|
|
-- MOVWF LCD_data,access
|
415 |
|
|
-- CALL Set_address
|
416 |
|
|
-- CALL Delay42us
|
417 |
|
|
--
|
418 |
|
|
-- MOVLW '<'
|
419 |
|
|
-- MOVWF LCD_data,access
|
420 |
|
|
-- CALL Display
|
421 |
|
|
-- CALL Delay42us
|
422 |
|
|
--
|
423 |
|
|
-- MOVLW '<'
|
424 |
|
|
-- MOVWF LCD_data,access
|
425 |
|
|
-- CALL Display
|
426 |
|
|
-- CALL Delay42us
|
427 |
|
|
--
|
428 |
|
|
-- MOVLW 0x63
|
429 |
|
|
-- MOVWF LCD_data,access
|
430 |
|
|
-- CALL Set_address
|
431 |
|
|
-- CALL Delay42us
|
432 |
|
|
--
|
433 |
|
|
-- MOVLW '<'
|
434 |
|
|
-- MOVWF LCD_data,access
|
435 |
|
|
-- CALL Display
|
436 |
|
|
-- CALL Delay42us
|
437 |
|
|
--
|
438 |
|
|
-- MOVLW '<'
|
439 |
|
|
-- MOVWF LCD_data,access
|
440 |
|
|
-- CALL Display
|
441 |
|
|
-- CALL Delay42us
|
442 |
|
|
--
|
443 |
|
|
--
|
444 |
|
|
-- ;----------------------
|
445 |
|
|
-- ; ~ 2second delay
|
446 |
|
|
-- MOVLW 0x22
|
447 |
|
|
-- MOVWF e4,access
|
448 |
|
|
--
|
449 |
|
|
--loop21:
|
450 |
|
|
-- CALL Delay58ms
|
451 |
|
|
-- DECFSZ e4,1,access
|
452 |
|
|
-- BRA loop21
|
453 |
|
|
--
|
454 |
|
|
-- MOVLW 0x80
|
455 |
|
|
-- MOVWF LATB
|
456 |
|
|
--
|
457 |
|
|
--looplooop:
|
458 |
|
|
-- RLNCF LATB,1,0
|
459 |
|
|
--
|
460 |
|
|
-- MOVLW SHIFT_D_L
|
461 |
|
|
-- MOVWF LCD_command,access
|
462 |
|
|
-- CALL Command
|
463 |
|
|
--
|
464 |
|
|
-- MOVLW 0x0f
|
465 |
|
|
-- ANDWF PORTA,0,0
|
466 |
|
|
--
|
467 |
|
|
-- MOVWF e4,0
|
468 |
|
|
--
|
469 |
|
|
-- INCF e4,1,0
|
470 |
|
|
--
|
471 |
|
|
--loop_3x58ms:
|
472 |
|
|
-- CALL Delay58ms
|
473 |
|
|
-- ;CALL Delay58ms
|
474 |
|
|
--
|
475 |
|
|
-- DECF e4,1,0
|
476 |
|
|
-- TSTFSZ e4,0
|
477 |
|
|
-- BRA loop_3x58ms
|
478 |
|
|
-- BRA looplooop
|
479 |
|
|
--
|
480 |
|
|
--
|
481 |
|
|
--; Fuctions:
|
482 |
|
|
--
|
483 |
|
|
--;---------------------------------
|
484 |
|
|
--; Delay 42us *********************
|
485 |
|
|
--Delay42us:
|
486 |
|
|
--
|
487 |
|
|
-- ;save working registers
|
488 |
|
|
-- movff STATUS,STATUS_TEMP1
|
489 |
|
|
-- movff WREG,WREG_TEMP1
|
490 |
|
|
-- movff BSR,BSR_TEMP1
|
491 |
|
|
--
|
492 |
|
|
-- MOVLW 0xAC
|
493 |
|
|
-- MOVWF e1,access
|
494 |
|
|
--
|
495 |
|
|
--loop10:
|
496 |
|
|
-- INCFSZ e1,1,access
|
497 |
|
|
-- BRA loop10
|
498 |
|
|
--
|
499 |
|
|
-- ;restore working registers
|
500 |
|
|
-- movff BSR_TEMP1,BSR
|
501 |
|
|
-- movff WREG_TEMP1,WREG
|
502 |
|
|
-- movff STATUS_TEMP1,STATUS
|
503 |
|
|
--
|
504 |
|
|
-- RETURN
|
505 |
|
|
--;******** end Delay 40us **********
|
506 |
|
|
--;----------------------------------
|
507 |
|
|
--
|
508 |
|
|
--
|
509 |
|
|
--;---------------------------------
|
510 |
|
|
--; Delay 1.6ms ********************
|
511 |
|
|
--Delay1_6ms:
|
512 |
|
|
--
|
513 |
|
|
-- ;save working registers
|
514 |
|
|
-- movff STATUS,STATUS_TEMP2
|
515 |
|
|
-- movff WREG,WREG_TEMP2
|
516 |
|
|
-- movff BSR,BSR_TEMP2
|
517 |
|
|
--
|
518 |
|
|
-- MOVLW 0x25
|
519 |
|
|
-- MOVWF e2,access
|
520 |
|
|
--
|
521 |
|
|
--loop3:
|
522 |
|
|
-- CALL Delay42us
|
523 |
|
|
-- DECFSZ e2,1,access
|
524 |
|
|
-- BRA loop3
|
525 |
|
|
--
|
526 |
|
|
-- ;restore working registers
|
527 |
|
|
-- movff BSR_TEMP2,BSR
|
528 |
|
|
-- movff WREG_TEMP2,WREG
|
529 |
|
|
-- movff STATUS_TEMP2,STATUS
|
530 |
|
|
--
|
531 |
|
|
-- RETURN
|
532 |
|
|
--;******** end Delay1.6ms **********
|
533 |
|
|
--;----------------------------------
|
534 |
|
|
--
|
535 |
|
|
--
|
536 |
|
|
--;---------------------------------
|
537 |
|
|
--; Delay 58ms *********************
|
538 |
|
|
--Delay58ms:
|
539 |
|
|
--
|
540 |
|
|
-- ;save working registers
|
541 |
|
|
-- movff STATUS,STATUS_TEMP3
|
542 |
|
|
-- movff WREG,WREG_TEMP3
|
543 |
|
|
-- movff BSR,BSR_TEMP3
|
544 |
|
|
--
|
545 |
|
|
-- MOVLW 0x24
|
546 |
|
|
-- MOVWF e3,access
|
547 |
|
|
--
|
548 |
|
|
--loop4:
|
549 |
|
|
-- CALL Delay1_6ms
|
550 |
|
|
-- DECFSZ e3,1,access
|
551 |
|
|
-- BRA loop4
|
552 |
|
|
--
|
553 |
|
|
-- ;restore working registers
|
554 |
|
|
-- movff BSR_TEMP3,BSR
|
555 |
|
|
-- movff WREG_TEMP3,WREG
|
556 |
|
|
-- movff STATUS_TEMP3,STATUS
|
557 |
|
|
--
|
558 |
|
|
-- RETURN
|
559 |
|
|
--;******** end Delay 58ms **********
|
560 |
|
|
--;----------------------------------
|
561 |
|
|
--
|
562 |
|
|
--
|
563 |
|
|
--;----------------------------------
|
564 |
|
|
--; send a command to the LCD *******
|
565 |
|
|
--Command:
|
566 |
|
|
--
|
567 |
|
|
-- ;save working registers
|
568 |
|
|
-- movff STATUS,STATUS_TEMP4
|
569 |
|
|
-- movff WREG,WREG_TEMP4
|
570 |
|
|
-- movff BSR,BSR_TEMP4
|
571 |
|
|
--
|
572 |
|
|
--MOVFF LCD_command,LCD_DATA_PRT
|
573 |
|
|
--BSF LCD_INST_PORT,E_PIN,0
|
574 |
|
|
--NOP
|
575 |
|
|
--NOP
|
576 |
|
|
--NOP
|
577 |
|
|
--BCF LCD_INST_PORT,E_PIN,0
|
578 |
|
|
--SWAPF LCD_DATA_PORT,1,0
|
579 |
|
|
--NOP
|
580 |
|
|
--NOP
|
581 |
|
|
--NOP
|
582 |
|
|
--NOP
|
583 |
|
|
--NOP
|
584 |
|
|
--NOP
|
585 |
|
|
--NOP
|
586 |
|
|
--NOP
|
587 |
|
|
--NOP
|
588 |
|
|
--NOP
|
589 |
|
|
--NOP
|
590 |
|
|
--BSF LCD_INST_PORT,E_PIN,0
|
591 |
|
|
--NOP
|
592 |
|
|
--NOP
|
593 |
|
|
--NOP
|
594 |
|
|
--BCF LCD_INST_PORT,E_PIN,0
|
595 |
|
|
--
|
596 |
|
|
-- ;restore working registers
|
597 |
|
|
-- movff BSR_TEMP4,BSR
|
598 |
|
|
-- movff WREG_TEMP4,WREG
|
599 |
|
|
-- movff STATUS_TEMP4,STATUS
|
600 |
|
|
--
|
601 |
|
|
--RETURN
|
602 |
|
|
--;****** end send command **********
|
603 |
|
|
--;----------------------------------
|
604 |
|
|
--
|
605 |
|
|
--
|
606 |
|
|
--;----------------------------------
|
607 |
|
|
--; send data to the LCD ************
|
608 |
|
|
--Display:
|
609 |
|
|
--
|
610 |
|
|
-- ;save working registers
|
611 |
|
|
-- movff STATUS,STATUS_TEMP4
|
612 |
|
|
-- movff WREG,WREG_TEMP4
|
613 |
|
|
-- movff BSR,BSR_TEMP4
|
614 |
|
|
--
|
615 |
|
|
--MOVFF LCD_data,LCD_DATA_PRT
|
616 |
|
|
--BSF LCD_INST_PORT,RS_PIN,0
|
617 |
|
|
--BSF LCD_INST_PORT,E_PIN,0
|
618 |
|
|
--NOP
|
619 |
|
|
--NOP
|
620 |
|
|
--NOP
|
621 |
|
|
--BCF LCD_INST_PORT,E_PIN,0
|
622 |
|
|
--SWAPF LCD_DATA_PORT,1,0
|
623 |
|
|
--NOP
|
624 |
|
|
--NOP
|
625 |
|
|
--NOP
|
626 |
|
|
--NOP
|
627 |
|
|
--NOP
|
628 |
|
|
--NOP
|
629 |
|
|
--NOP
|
630 |
|
|
--NOP
|
631 |
|
|
--NOP
|
632 |
|
|
--NOP
|
633 |
|
|
--NOP
|
634 |
|
|
--BSF LCD_INST_PORT,E_PIN,0
|
635 |
|
|
--NOP
|
636 |
|
|
--NOP
|
637 |
|
|
--NOP
|
638 |
|
|
--BCF LCD_INST_PORT,E_PIN,0
|
639 |
|
|
--BCF LCD_INST_PORT,RS_PIN,0
|
640 |
|
|
--
|
641 |
|
|
-- ;restore working registers
|
642 |
|
|
-- movff BSR_TEMP4,BSR
|
643 |
|
|
-- movff WREG_TEMP4,WREG
|
644 |
|
|
-- movff STATUS_TEMP4,STATUS
|
645 |
|
|
--
|
646 |
|
|
--RETURN
|
647 |
|
|
--;******** end send data ***********
|
648 |
|
|
--;----------------------------------
|
649 |
|
|
--
|
650 |
|
|
--;----------------------------------
|
651 |
|
|
--; Set an address to the LCD *******
|
652 |
|
|
--Set_address:
|
653 |
|
|
--
|
654 |
|
|
-- ;save working registers
|
655 |
|
|
-- movff STATUS,STATUS_TEMP4
|
656 |
|
|
-- movff WREG,WREG_TEMP4
|
657 |
|
|
-- movff BSR,BSR_TEMP4
|
658 |
|
|
--
|
659 |
|
|
--MOVLW 0x80
|
660 |
|
|
--IORWF LCD_data,1,access
|
661 |
|
|
--
|
662 |
|
|
--MOVFF LCD_data,LCD_DATA_PRT
|
663 |
|
|
--BSF LCD_INST_PORT,E_PIN,0
|
664 |
|
|
--NOP
|
665 |
|
|
--NOP
|
666 |
|
|
--NOP
|
667 |
|
|
--BCF LCD_INST_PORT,E_PIN,0
|
668 |
|
|
--SWAPF LCD_DATA_PORT,1,0
|
669 |
|
|
--NOP
|
670 |
|
|
--NOP
|
671 |
|
|
--NOP
|
672 |
|
|
--NOP
|
673 |
|
|
--NOP
|
674 |
|
|
--NOP
|
675 |
|
|
--NOP
|
676 |
|
|
--NOP
|
677 |
|
|
--NOP
|
678 |
|
|
--NOP
|
679 |
|
|
--NOP
|
680 |
|
|
--BSF LCD_INST_PORT,E_PIN,0
|
681 |
|
|
--NOP
|
682 |
|
|
--NOP
|
683 |
|
|
--NOP
|
684 |
|
|
--BCF LCD_INST_PORT,E_PIN,0
|
685 |
|
|
--
|
686 |
|
|
-- ;restore working registers
|
687 |
|
|
-- movff BSR_TEMP4,BSR
|
688 |
|
|
-- movff WREG_TEMP4,WREG
|
689 |
|
|
-- movff STATUS_TEMP4,STATUS
|
690 |
|
|
--
|
691 |
|
|
--RETURN
|
692 |
|
|
--;******** end set address *********
|
693 |
|
|
--;----------------------------------
|
694 |
|
|
--
|
695 |
|
|
--
|
696 |
|
|
--;******************************************************************************
|
697 |
|
|
--;End of program
|
698 |
|
|
--
|
699 |
|
|
-- END
|