如题,在做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);
}
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
============lcd_hw.h=================
//header file for on-board lcd hardware
//hardware configuration
#define LCD_PS LCD_PS1x //lcd prescaler
#define LCD_COM LCD_COM1 //lcd com
//#define LCD_DIGs 8 //number of lcd digits
//end hardware configuration
#define LCD_COM0 0x00 //com0 - static
#define LCD_COM1 0x01 //com0..1 -> 1/2
#define LCD_COM2 0x02 //com0..2 -> 1/3
#define LCD_COM3 0x03 //com0..3 -> 1/4
//prescaler settings
#define LCD_PS1x 0x00
#define LCD_PS2x 0x01
#define LCD_PS3x 0x02
#define LCD_PS4x 0x03
#define LCD_PS5x 0x04
#define LCD_PS6x 0x05
#define LCD_PS7x 0x06
#define LCD_PS8x 0x07
#define LCD_PS9x 0x08
#define LCD_PS10x 0x09
#define LCD_PS11x 0x0a
#define LCD_PS12x 0x0b
#define LCD_PS13x 0x0c
#define LCD_PS14x 0x0d
#define LCD_PS15x 0x0e
#define LCD_PS16x 0x0f
//global variable
//initialize the lcd
void lcd_init(void);
//display data on lcd
//vRAM is an array containing the numerical digits
void lcd_display(unsigned char * vRAM);
一周热门 更多>