如题,在做PIC16F1937段式LCD程序时,不知道怎么回事段式LCD一直点不亮,还请高手帮帮忙,谢谢!
SEG0~SEG9 COM0~COM3
代码如下:
#include <pic16f1937.h>
//-------------------------------------------------------------------------------//
//函数名:Init_Port //
//功能:初始化I/O口 //
//------------------------------------------------------------------------------//
void Init_Port(void)
{
TRISA = 0x00;
TRISB = 0x00;
TRISC = 0x00;
TRISD = 0x00;
TRISE = 0x00;
//////////////
PORTA = 0x00;
PORTB = 0x00;
PORTC = 0x00;
PORTD = 0x00;
PORTE = 0x00;
}
//-------------------------------------------------------------------------------//
//函数名:lcd_init //
//功能:lcd初始化 //
//------------------------------------------------------------------------------//
void lcd_init(void)
{
LCDCON=0b10011111;//
//|||||||+---LMUX0
//||||||+----LMUX1 11--1/4
//|||||+-----CS0 00=FOSC/8192,01 = T1OSC (Timer1) /32,
//||||+-----CS1 1x=LFINTOSC(31 kHz) /32
//|||+------VLCDEN
//||+-------WERR
//|+--------#SLPEN
//+---------LCDEN
LCDPS=0b00110000;//
//|||||||+---LP0 1111 = 1:16
//||||||+----LP1
//|||||+-----LP2
//||||+-----LP3 0000=1:1
//|||+------WA 1 = 允许写入LCDDATAx 寄存器
//||+-------LCDA 1 = 使能LCD 驱动模块
//|+--------BIASMD当LMUX<1:0>=11时:0=1/3偏置模式(不要将该位置1)
//+---------WFT 1在每一帧边界改变相位0在每一公共端类型内改变相位
//LCDREF=0B11101110;
//
LCDSE0=0b11111111;
LCDSE1=0b00000011;//LCD引脚使能寄存器,SEG0~SEG9
}
//-------------------------------------------------------------------------------//
//函数名:main //
//功能:主程序入口函数 //
//------------------------------------------------------------------------------//
void main(void)
{
unsigned char i;
INTCON=0;//关闭总中断,禁止外设,timer0,外部,电平中断,清除timer0,外部,电平中断标志
ANSELA =0x00;
ANSELB =0x00;
//ANSELC =0x00;
ANSELD =0x00;
ANSELE =0x00;
Init_Port();
lcd_init();
LCDDATA0=0xfc;
LCDDATA3=0xfc;
LCDDATA6=0xfc;
LCDDATA9=0xfc;
while(1)
{
LCDDATA0 = 0XFF;
DelayMs(500);
LCDDATA0 = 0X00;
DelayMs(500);
}
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
well said.
sometimes, people are too stupid to help themselves.
because you fail to read the datasheet and understand it before writing your code.
if that's what you are capable of, you are months away from being able to run the lcd.
-----------------------------------------------------------------------
还是先检查硬件吧。请看我的硬件连接图。要仔细检查每个点的连通情形。
(原文件名:lcd drive110825.jpg)
一周热门 更多>