12864—12的控制芯片是T6963C,怎样用C语言(基于msp430单片机的)写显示程序啊?我是初学者,对这个不是很了解,希望得到大家的帮助,谢谢!
补充
用这个程序12864-12显示不了啊,为什么?请教高手
#include"msp430g2553.h"
#define SENDCOMM 0XF8 //0XF1000
#define READCOMM 0XFC //0XF1100
#define SENDDATA 0XFA //0XF1010
#define READDATA 0XFE //0XF1110
#define E_CLK_0 P2OUT &= ~BIT5 //时钟信号为0
#define E_CLK_1 P2OUT |= BIT5 //时钟信号为1
#define RW_SID_0 P2OUT &= ~BIT4 //数据信号为0
#define RW_SID_1 P2OUT |= BIT4 //数据信号为1
void MCU_initialize(void);
void LCD_send_byte(unsigned char a);
void LCD_comm(unsigned char comm);
void LCD_data(unsigned char lcd_data);
void LCD_setxy(unsigned char x,unsigned char y);
void LCD_WriteStr(unsigned char dis_addr_x,unsigned char dis_addr_y,char* str);
void LCD_init(void);
void main()
{
MCU_initialize();
LCD_init();
LCD_WriteStr(1,1,"浙江");
LCD_WriteStr(1,2,"信电");
while(1);
}
void MCU_initialize(void)
{
WDTCTL = WDTPW + WDTHOLD;
//BCSCTL1 = CALBC1_8MHZ;
//DCOCTL = CALDCO_8MHZ;
P2DIR = 0xFF;
P2OUT = 0x00;
}
void LCD_send_byte(unsigned char a)
{
unsigned char i;
for(i=8;i>0;i--)
{
if(a&(0x01<<(i-1)))
RW_SID_1;
else
RW_SID_0;
_delay_cycles(100);
E_CLK_1;
_delay_cycles(100);
E_CLK_0;
_delay_cycles(100);
}
}
void LCD_comm(unsigned char comm)
{
unsigned char temp;
_delay_cycles(100);
LCD_send_byte(SENDCOMM);
temp=comm&0XF0;
LCD_send_byte(temp);
temp=((comm&0X0F)<<4)&0XF0;
LCD_send_byte(temp);
_delay_cycles(100);
}
void LCD_data(unsigned char lcd_data) //写数据
{
unsigned char temp;
_delay_cycles(100);
LCD_send_byte(SENDDATA);
temp=lcd_data&0xf0;
LCD_send_byte(temp);
temp=(lcd_data&0X0F)<<4;
LCD_send_byte(temp);
_delay_cycles(100);
}
void LCD_setxy(unsigned char x,unsigned char y) //设置显示位置 X(1~16),Y(1~4)
{
switch(y)
{
case 1:
LCD_comm(0X80+x);break;
case 2:
LCD_comm(0X90+x);break;
case 3:
LCD_comm(0X88+x);break;
case 4:
LCD_comm(0X98+x);break;
default:break;
}
}
void LCD_WriteStr(unsigned char dis_addr_x,unsigned char dis_addr_y,char* str)
{
unsigned char LCD_temp;
LCD_setxy(dis_addr_x,dis_addr_y);
LCD_temp=*str;
while(LCD_temp != 0x00)
{
LCD_data(LCD_temp);
LCD_temp=*(++str);
}
}
void LCD_init(void)
{
_delay_cycles(300);
LCD_comm(0x30);//一次送8位数据
LCD_comm(0x0c);//整体显示,游标off,游标位置off
LCD_comm(0x01);//清DDRAM
LCD_comm(0x02);//DDRAM地址归位
LCD_comm(0x80);//设定DDRAM 7位地址000,0000到地址计数器AC
}
补充
用这个程序12864-12显示不了啊,为什么?请教高手
#include"msp430g2553.h"
#define SENDCOMM 0XF8 //0XF1000
#define READCOMM 0XFC //0XF1100
#define SENDDATA 0XFA //0XF1010
#define READDATA 0XFE //0XF1110
#define E_CLK_0 P2OUT &= ~BIT5 //时钟信号为0
#define E_CLK_1 P2OUT |= BIT5 //时钟信号为1
#define RW_SID_0 P2OUT &= ~BIT4 //数据信号为0
#define RW_SID_1 P2OUT |= BIT4 //数据信号为1
void MCU_initialize(void);
void LCD_send_byte(unsigned char a);
void LCD_comm(unsigned char comm);
void LCD_data(unsigned char lcd_data);
void LCD_setxy(unsigned char x,unsigned char y);
void LCD_WriteStr(unsigned char dis_addr_x,unsigned char dis_addr_y,char* str);
void LCD_init(void);
void main()
{
MCU_initialize();
LCD_init();
LCD_WriteStr(1,1,"浙江");
LCD_WriteStr(1,2,"信电");
while(1);
}
void MCU_initialize(void)
{
WDTCTL = WDTPW + WDTHOLD;
//BCSCTL1 = CALBC1_8MHZ;
//DCOCTL = CALDCO_8MHZ;
P2DIR = 0xFF;
P2OUT = 0x00;
}
void LCD_send_byte(unsigned char a)
{
unsigned char i;
for(i=8;i>0;i--)
{
if(a&(0x01<<(i-1)))
RW_SID_1;
else
RW_SID_0;
_delay_cycles(100);
E_CLK_1;
_delay_cycles(100);
E_CLK_0;
_delay_cycles(100);
}
}
void LCD_comm(unsigned char comm)
{
unsigned char temp;
_delay_cycles(100);
LCD_send_byte(SENDCOMM);
temp=comm&0XF0;
LCD_send_byte(temp);
temp=((comm&0X0F)<<4)&0XF0;
LCD_send_byte(temp);
_delay_cycles(100);
}
void LCD_data(unsigned char lcd_data) //写数据
{
unsigned char temp;
_delay_cycles(100);
LCD_send_byte(SENDDATA);
temp=lcd_data&0xf0;
LCD_send_byte(temp);
temp=(lcd_data&0X0F)<<4;
LCD_send_byte(temp);
_delay_cycles(100);
}
void LCD_setxy(unsigned char x,unsigned char y) //设置显示位置 X(1~16),Y(1~4)
{
switch(y)
{
case 1:
LCD_comm(0X80+x);break;
case 2:
LCD_comm(0X90+x);break;
case 3:
LCD_comm(0X88+x);break;
case 4:
LCD_comm(0X98+x);break;
default:break;
}
}
void LCD_WriteStr(unsigned char dis_addr_x,unsigned char dis_addr_y,char* str)
{
unsigned char LCD_temp;
LCD_setxy(dis_addr_x,dis_addr_y);
LCD_temp=*str;
while(LCD_temp != 0x00)
{
LCD_data(LCD_temp);
LCD_temp=*(++str);
}
}
void LCD_init(void)
{
_delay_cycles(300);
LCD_comm(0x30);//一次送8位数据
LCD_comm(0x0c);//整体显示,游标off,游标位置off
LCD_comm(0x01);//清DDRAM
LCD_comm(0x02);//DDRAM地址归位
LCD_comm(0x80);//设定DDRAM 7位地址000,0000到地址计数器AC
}