完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我这有段程序关于最后LCD显示的程序,求高手解释
LCD及真值表 Compiled using PICC 9.50 #include "pic.h" //函数声明 void Init946();//初始化946 void InitLcd();//初始化LCD寄存器 void UpdateLCD(void);//显示LCD // unsigned index,segment; void Init946() // Initialize the PIC16C914 { PORTA = 0; // Clear ports A,B,C PORTB = 0; PORTC = 0; PORTD = 0; TRISA = 0; // All RA are digital outputs TRISB = 0; TRISC = 0; TRISD = 0; ADCON1 =0x07; // RA are digital GIE = 0; // Enable global interrupts } void InitLcd() { WFT=0; //A波型 //帧时钟予分频比 LP0=1; LP1=1; LP2=0; LP3=0; //引脚配置段驱动 LCDSE0=0XFF; LCDSE1=0XFF; LCDSE2=0XFF; //配置休眠模式 SLPEN=0; //休眠模式下使能LCD模块 //写像数全亮 LCDDATA0=0xFF; LCDDATA1=0xFF; LCDDATA2=0xFF; LCDDATA3=0xFF; LCDDATA4=0xFF; LCDDATA5=0xFF; LCDDATA6=0xFF; LCDDATA7=0xFF; LCDDATA8=0xFF; LCDDATA9=0xFF; LCDDATA10=0xFF; LCDDATA11=0xFF; LCDDATA12=0xFF; LCDDATA13=0xFF; LCDDATA14=0xFF; LCDDATA15=0xFF; //清LCD中断标记位 VLCDEN=0;//引脚 //复用和偏置模式 LMUX0=1; LMUX1=1; //1/4复用 BIASMD=0; //1/3偏置 //配置时钟源 CS0=0; CS1=1; //WDT31KHZ/32 //使能偏置电压引脚 VLCDEN=1;//使能引脚 //使能LCD模块 //LCDA=1; //工作状态位使能LCD驱动模块 LCDEN=1; //驱动使能位使能LCD驱动模块 } void UpdateLCD(void) { // Array of 7-segment numbers // gfedcba const unsigned char SevenSegTable[16]={ 0b00111111, // 0 0b00000110, // 1 0b01011011, // 2 0b01001111, // 3 0b01100110, // 4 0b01101101, // 5 0b01111101, // 6 0b00000111, // 7 0b01111111, // 8 0b01101111, // 9 0b01110111, // A 0b01111100, // B 0b01011000, // C 0b01011110, // D 0b01111001, // E 0b01110001};// F // clear all LCD data RAM LCDDATA0=0; LCDDATA1=0; LCDDATA2=0; LCDDATA3=0; LCDDATA4=0; LCDDATA5=0; LCDDATA6=0; LCDDATA7=0; LCDDATA8=0; LCDDATA9=0; LCDDATA10=0; LCDDATA11=0; LCDDATA12=0; LCDDATA13=0; LCDDATA14=0; LCDDATA15=0; // Sunday LCDDATA0 = LCDDATA0|0x01; // Monday LCDDATA0 = LCDDATA0|0x02; // Tuesday LCDDATA0 = LCDDATA0|0x04; // Wednesday LCDDATA0 = LCDDATA0|0x08; // Thursday LCDDATA1 = LCDDATA1|0x01; // Friday LCDDATA0 = LCDDATA0|0x10; // Saturday LCDDATA0 = LCDDATA0|0x20; // Digit 1 LCDDATA11 = LCDDATA11|0x01; // Digit 2 index = 2; segment = SevenSegTable[index]; if(segment&0x01) // D2.a LCDDATA13 = LCDDATA13|0x08; if(segment&0x02) // D2.b LCDDATA12 = LCDDATA12|0x02; if(segment&0x04) // D2.c LCDDATA5 = LCDDATA5|0x08; if(segment&0x08) // D2.d LCDDATA1 = LCDDATA1|0x08; if(segment&0x10) // D2.e LCDDATA4 = LCDDATA4|0x01; if(segment&0x20) // D2.f LCDDATA8 = LCDDATA8|0x01; if(segment&0x40) // D2.g LCDDATA9 = LCDDATA9|0x08; // Digit 3 index = 3; segment = SevenSegTable[index]; if(segment&0x01) // D3.a LCDDATA13 = LCDDATA13|0x04; if(segment&0x02) // D3.b LCDDATA8 = LCDDATA8|0x04; if(segment&0x04) // D3.c LCDDATA4 = LCDDATA4|0x04; if(segment&0x08) // D3.d LCDDATA1 = LCDDATA1|0x04; if(segment&0x10) // D3.e LCDDATA4 = LCDDATA4|0x02; if(segment&0x20) // D3.f LCDDATA9 = LCDDATA9|0x04; if(segment&0x40) // D3.g LCDDATA5 = LCDDATA5|0x04; // Digit 4 index = 4; segment = SevenSegTable[index]; if(segment&0x01) // D4.a LCDDATA13 = LCDDATA13|0x02; if(segment&0x02) // D4.b LCDDATA8 = LCDDATA8|0x08; if(segment&0x04) // D4.c LCDDATA4 = LCDDATA4|0x08; if(segment&0x08) // D4.d LCDDATA1 = LCDDATA1|0x02; if(segment&0x10) // D4.e LCDDATA5 = LCDDATA5|0x02; if(segment&0x20) // D4.f LCDDATA12 = LCDDATA12|0x04; if(segment&0x40) // D4.g LCDDATA9 = LCDDATA9|0x02; // Digit 5 index = 5; segment = SevenSegTable[index]; if(segment&0x01) // D5.a LCDDATA12 = LCDDATA12|0x80; if(segment&0x02) // D5.b LCDDATA12 = LCDDATA12|0x10; if(segment&0x04) // D5.c LCDDATA4 = LCDDATA4|0x10; if(segment&0x08) // D5.d LCDDATA0 = LCDDATA0|0x80; if(segment&0x10) // D5.e LCDDATA4 = LCDDATA4|0x80; if(segment&0x20) // D5.f LCDDATA13 = LCDDATA13|0x01; if(segment&0x40) // D5.g LCDDATA8 = LCDDATA8|0x80; // Digit 6 index = 6; segment = SevenSegTable[index]; if(segment&0x01) // D6.a LCDDATA12 = LCDDATA12|0x40; if(segment&0x02) // D6.b LCDDATA8 = LCDDATA8|0x20; if(segment&0x04) // D6.c LCDDATA4 = LCDDATA4|0x20; if(segment&0x08) // D6.d LCDDATA0 = LCDDATA0|0x40; if(segment&0x10) // D6.e LCDDATA4 = LCDDATA4|0x40; if(segment&0x20) // D6.f LCDDATA8 = LCDDATA8|0x10; if(segment&0x40) // D6.g LCDDATA8 = LCDDATA8|0x40; }
|
|
相关推荐
|
|
怎么解释,哪个地方不明白, 这个是数码管的段式显示
|
|
|
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
求解外围电路实现的是4脚给持续低电平复位并正常工作,高电平不工作的原因
2077 浏览 1 评论
3497 浏览 3 评论
PIC1946程序有一个变量在运行过程中恢复初始值其他变量保持不变
2330 浏览 2 评论
2757 浏览 0 评论
PIC16F1825的RC5引脚,在主程序中操作无效,在中断中可以改变是为什么?
4015 浏览 5 评论
963浏览 0评论
用XC8编译PIC18F25K80时提示下面Error,求怎么解决这个问题
6347浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-25 17:46 , Processed in 0.900188 second(s), Total 102, Slave 79 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号