亚洲春色中文字幕久久久-三上亚,一吻二脱三床四吻胸,国产真实伦对白视频全集,在线毛片观看,精品成品入口黄网,国产毛aⅴ片久久久,亚洲AV色香蕉一区二区三区老师,萧皇后A级艳片,色情日本视频更新,99久久亚洲精品日本无码
標(biāo)題:
MC9S12XS128并口12864液晶顯示程序,包含按鍵中斷,按鍵可翻動的程序源碼
[打印本頁]
作者:
123zyb
時(shí)間:
2017-10-24 15:19
標(biāo)題:
MC9S12XS128并口12864液晶顯示程序,包含按鍵中斷,按鍵可翻動的程序源碼
程序在12864液晶上顯示一首詞,按鍵可翻動詞句。
0.png
(6.42 KB, 下載次數(shù): 79)
下載附件
2017-10-25 00:29 上傳
單片機(jī)源程序如下:
/*---------------------------------------------------------*/
/************************************************************
飛翔科技MC9S12XS128汽車電子開發(fā)板
************************************************************/
/*---------------------------------------------------------*/
#include <hidef.h> /* common defines and macros */
#include "derivative.h" /* derivative-specific definitions */
#include "LCD.h"
#define LEDCPU PORTK_PK4
#define LEDCPU_dir DDRK_DDRK4
#define KEY1 PTIH_PTIH3
#define KEY2 PTIH_PTIH2
#define KEY1_dir DDRH_DDRH3
#define KEY2_dir DDRH_DDRH2
#define BUS_CLOCK 32000000 //總線頻率
#define OSC_CLOCK 16000000 //晶振頻率
char *poem[11] = {
"長征",
"毛澤東",
"紅軍不怕遠(yuǎn)征難,",
"萬水千山只等閑,",
"五嶺逶迤騰細(xì)浪,",
"烏蒙磅礴走泥丸。",
"金沙水拍云崖暖,",
"大渡橋橫鐵索寒,",
"更喜岷山千里雪,",
"三軍過后盡開顏!",
"",
} ;
unsigned char single = 0; //液晶翻頁的標(biāo)志符
/*************************************************************/
/* 初始化鎖相環(huán) */
/*************************************************************/
void INIT_PLL(void)
{
CLKSEL &= 0x7f; //set OSCCLK as sysclk
PLLCTL &= 0x8F; //Disable PLL circuit
CRGINT &= 0xDF;
#if(BUS_CLOCK == 40000000)
SYNR = 0x44;
#elif(BUS_CLOCK == 32000000)
SYNR = 0x43;
#elif(BUS_CLOCK == 24000000)
SYNR = 0x42;
#endif
REFDV = 0x81; //PLLCLK=2×OSCCLK×(SYNDIV+1)/(REFDIV+1)=64MHz ,fbus=32M
PLLCTL =PLLCTL|0x70; //Enable PLL circuit
asm NOP;
asm NOP;
while(!(CRGFLG&0x08)); //PLLCLK is Locked already
CLKSEL |= 0x80; //set PLLCLK as sysclk
}
/************************************************************/
/* 初始化ECT模塊 */
/************************************************************/
void initialize_ect(void){
TSCR1_TFFCA = 1; // 定時(shí)器標(biāo)志位快速清除
TSCR1_TEN = 1; // 定時(shí)器使能位. 1=允許定時(shí)器正常工作; 0=使主定時(shí)器不起作用(包括計(jì)數(shù)器)
TIOS = 0xff; //指定所有通道為輸出比較方式
TCTL1 = 0x00; // 后四個(gè)通道設(shè)置為定時(shí)器與輸出引腳斷開
TCTL2 = 0x00; // 前四個(gè)通道設(shè)置為定時(shí)器與輸出引腳斷開
TIE = 0x00; // 禁止所有通道定時(shí)中斷
TSCR2 = 0x07; // 預(yù)分頻系數(shù)pr2-pr0:111,,時(shí)鐘周期為4us,
TFLG1 = 0xff; // 清除各IC/OC中斷標(biāo)志位
TFLG2 = 0xff; // 清除自由定時(shí)器中斷標(biāo)志位
}
/*************************************************************/
/* 初始化按鍵 */
/*************************************************************/
void init_key(void)
{
KEY1_dir =0; //設(shè)置為輸入
KEY2_dir=0;
PPSH = 0x00; //極性選擇寄存器,選擇下降沿;
PIFH = 0x0C; //對PIFH的每一位寫1來清除標(biāo)志位;
PIEH = 0x0C; //中斷使能寄存器;
}
/*************************************************************/
/* 按鍵中斷函數(shù) */
/*************************************************************/
#pragma CODE_SEG __NEAR_SEG NON_BANKED
interrupt void PTH_inter(void)
{
if(PIFH != 0) //判斷中斷標(biāo)志
{
PIFH = 0xff; //清除中斷標(biāo)志
if(KEY2 == 0)
{
delay1ms(5);
if(KEY2 == 0)
{
if(single == 0)
single = 10;
else single-=1;
}
}
if(KEY1 == 0)
{
delay1ms(5);
if(KEY1 == 0)
{
if(single == 10)
single = 0;
else single+=1;
}
}
lcd_clear();
if(single == 0) {
lcd_string(0,2,poem[0]);
lcd_string(1,3,poem[1]);
lcd_string(2,0,poem[2]);
lcd_string(3,0,poem[3]);
}
else if(single == 1) {
lcd_string(0,3,poem[1]);
lcd_string(1,0,poem[2]);
lcd_string(2,0,poem[3]);
lcd_string(3,0,poem[4]);
}
else if(single == 2) {
lcd_string(0,0,poem[2]);
lcd_string(1,0,poem[3]);
lcd_string(2,0,poem[4]);
lcd_string(3,0,poem[5]);
}
else if(single == 8) {
lcd_string(0,0,poem[8]);
lcd_string(1,0,poem[9]);
lcd_string(2,0,poem[10]);
lcd_string(3,2,poem[0]);
}
else if(single == 9) {
lcd_string(0,0,poem[9]);
lcd_string(1,0,poem[10]);
lcd_string(2,2,poem[0]);
lcd_string(3,3,poem[1]);
}
else if(single == 10) {
lcd_string(0,0,poem[10]);
lcd_string(1,2,poem[0]);
lcd_string(2,3,poem[1]);
lcd_string(3,0,poem[2]);
}
else {
lcd_string(0,0,poem[single]);
lcd_string(1,0,poem[single + 1]);
lcd_string(2,0,poem[single + 2]);
lcd_string(3,0,poem[single + 3]);
}
}
}
#pragma CODE_SEG DEFAULT
/*************************************************************/
/* 主函數(shù) */
……………………
…………限于本文篇幅 余下代碼請從51黑下載附件…………
復(fù)制代碼
完整代碼下載:
20并口液晶.rar
(238.55 KB, 下載次數(shù): 28)
2017-10-24 15:18 上傳
點(diǎn)擊文件名下載附件
程序源碼
下載積分: 黑幣 -5
歡迎光臨 (http://www.denmoz.com/bbs/)
Powered by Discuz! X3.1