全球主流8位MCU芯片詳細解剖No.1:飛思卡爾 MC9S08AC60
void lcd_write_char(unsigned char x,unsigned char y,unsigned char ch) {
if(y)
lcd_write_cmd(0xc0+x);
else
lcd_write_cmd(0x80+x);
lcd_write_data(ch);
}
void lcd_write_str(unsigned char x,unsigned char y,char*s) {
if(y)
lcd_write_cmd(0xc0+x);
else
lcd_write_cmd(0x80+x);
while(*s){
lcd_write_data(*s);
s++;
}
}
main.c
#include /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
#include "mc9s08ac16.h"
#include "lcd1602.h"
const unsigned char table[10]={‘0’,‘1’,‘2’,‘3’,‘4’,‘5’,‘6’,‘7’,‘8’,‘9’};
unsigned char hour=11,minute=20,second=0;
unsigned char con_result[9];
void init_system_clk(void)
{
ICGC1=0xf8;
ICGC2=0x89;
while(ICGS1_LOCK==0);
}
void convert() /*covert numeric data to char data,for instance,1 to ‘1’ */
{
unsigned char tens,unit;
tens=second/10;
unit=second%10;
con_result[7]=table[unit];
con_result[6]=table[tens];
tens=minute/10;
unit=minute%10;
con_result[4]=table[unit];
con_result[3]=table[tens];
tens=hour/10;
unit=hour%10;
con_result[1]=table[unit];
con_result[0]=table[tens];
con_result[8]=‘