/***********************************************
**** LAUNCH PAD 学习之GPIOINT ***
**** MCU: MSP430 ***
**** 作者:孙祖祥 ***
**** ***
**** ***
**** 2012.05.24.20:16 ***
**** 实验现象:LCD ***
**** ***
****P1.0~P1.7 数据口 P2.0 P2.1 P2.2 en rs Psb ***
***********************************************/
#include "msp430g2553.h"
//#include <ti/mcu/msp430/csl/CSL.h> //Grace
#define uchar unsigned char
#define uint unsigned int
unsigned char table[]="EE-LaunchPad";
unsigned char num;
void delay_1ms(void)
{
unsigned int i;
for (i=0;i<1140;i++);
}
void delay_nms(unsigned int n)
{
unsigned int i=0;
for (i=0;i<n;i++)
delay_1ms();
}
void write_com(unsigned int com)
{
P2OUT&= 0xfd;
P1OUT = com;
delay_nms(5);
P2OUT|= 0x01;
delay_nms(5);
P2OUT&= 0xfe;
}
void write_dat(unsigned int dat)
{
P2OUT |= 0x02;
P1OUT = dat;
delay_nms(5);
P2OUT|= 0x01;
delay_nms(5);
P2OUT&= 0xfe;
}
void disp_12864(uchar addr,const uchar *pt,uchar num)
{
uchar i;
write_com(addr);
for(i=0;i<(num*2);i++)
write_dat(*(pt++));
}
void init()
{
//PSB=1;//并口模式
P2OUT |= BIT2;
delay_nms(15);
P2OUT&= 0xfe;
delay_nms(5);
write_com(0x30);
delay_nms(1);
write_com(0x08);//清屏
delay_nms(1);
write_com(0x0c);//开显示,关光标
delay_nms(1);
write_com(0x01);//光标右移
delay_nms(1);
write_com(0x06);//第一行显示位置
delay_nms(1);
}
void main(void)
{
// CSL_init(); //Grace初始化配置,包含头文件
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1REN |= 0X0F;
P2REN = 0XFF;
P1DIR |= 0xff; // P1.2 output
P2DIR |= 0xff;
init();
while(1)
{
disp_12864(0x80,table,6);
delay_1ms();
disp_12864(0x90,"测试",6);
delay_1ms();
//while(1);
}
}
从屏幕的侧面看有微弱的显示,对光我接地,wr也接地。调好几天了,第一次用430.还有就是430系列的F 或者G 之类的寄存器都是通用的吗,如何配置外部晶振,求解?谢啦
此帖出自
小平头技术问答
一周热门 更多>