Hardware Reference
In-Depth Information
lcd_E
equ
$02
; E signal pin
lcd_RS
equ
$01
; RS signal pin
org
$1500
lds
#$1500
; set up stack pointer
jsr
openLCD
; initialize the LCD
ldx
#msg1
jsr
putsLCD
ldaa
#$C0
; move to the second row
jsr
cmd2LCD
;
ldx
#msg2
jsr
putsLCD
swi
msg1
dc.b
“hello world!”,0
msg2
dc.b
“LCD is working!”,0
#include “c:\miniIDE\delay.asm”
; include delay routines here
;
; include the previous four LCD functions
;
;
org
$FFFE
; uncomment this line for CodeWarrior
dc.w
start
; uncomment this line for CodeWarrior
end
Example 7.6
Write the C language versions of the previous four LCD functions and a program to test them.
Solution: The C functions for the LCD kit on the Dragon12 demo board and their test program
are as follows:
#include
“c:\cwHCS12\include\hcs12.h”
#include
“c:\cwHCS12\include\delay.h”
#include
“c:\cwHCS12\include\lcd_util.h”
#define
LCD_DAT PORTK // Port K drives LCD data pins, E, and RS
#define
LCD_DIR DDRK // Direction of LCD port
#define
LCD_E 0x02 // E signal
#define
LCD_RS 0x01 // RS signal
#define
LCD_E_RS 0x03 // assert both E and RS signals
void main (void)
{
char *msg1 5 “hello world!”;
char *msg2 5 “LCD is working!”;
openLCD();
putsLCD(msg1);
cmd2LCD(0xC0);
// move cursor to 2nd row, 1st column
putsLCD(msg2);
asm(“swi”);
while(1);
}
void cmd2LCD
(char cmd)
{
char
temp;
Search WWH ::




Custom Search