新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > MC9S12XS128驅(qū)動(dòng)LEDP10顯示屏

MC9S12XS128驅(qū)動(dòng)LEDP10顯示屏

作者: 時(shí)間:2016-11-27 來(lái)源:網(wǎng)絡(luò) 收藏
void hangxuan(unsigned char P)
{
A=P&0x01;
B=(P>>1)&0x01;
C=(P>>2)&0X01;
D=(P>>3)&0X01;
CT=1;
}
void init()
{
DisableInterrupts;
SC=0;
CP=0;
A=0;
B=0;
C=0;
D=0;
RI=0;
CT=1;
DIR=0XFF;
EnableInterrupts;
}
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
}
void timer_init()
{
//CLKSEL &= 0x7f; //set OSCCLK as sysclk
TSCR1_PRNT=0;//使能預(yù)分頻
TSCR2=0x87;//使能溢出中斷 128分頻
TCNTH=((unsigned int)(-20000))/256; //500ms
TCNTL=((unsigned int)(-20000))%6;
TFLG2_TOF=1; //清除溢出中斷標(biāo)志位
TSCR1_TEN=1; //使能定時(shí)器
}
#pragma CODE_SEG __NEAR_SEG NON_BANKED
interrupt void timer()
{
TFLG2_TOF=1; //清除溢出中斷標(biāo)志位
TCNTH=((unsigned int)(-20000))/256; //500ms
TCNTL=((unsigned int)(-20000))%6;
shu++;
if(shu==128)
{
shu=0;
}
}

上一頁(yè) 1 2 下一頁(yè)

關(guān)鍵詞: MC9S12XS128LEDP10顯示

評(píng)論


技術(shù)專區(qū)

關(guān)閉