}
void Ini_Lcd(void) {
Delay_Nms(500);
Write_Cmd(0x30); //基本指令集 Delay_1ms();
Write_Cmd(0x02); // 地址归位 Delay_1ms(); }
void pos(uchar x,uchar y)//x:1,2,3,4 {
//y:1,2,3,4,5,6,7,8
//x行y列
uchar pos;
Write_Cmd(0x0c); //整体显示打开,游标关闭 Write_Cmd(0x01); //清除显示 Write_Cmd(0x06); //游标右移
Write_Cmd(0x80); //设定显示的起始地址 Delay_1ms(); Delay_1ms(); Delay_1ms();
}
P2OUT&=~CS; //CS=0; Delay_Nms(10);
flag=SID&((i_data&0x80)>>6); if(flag)P2OUT|=SID; else P2OUT&=~SID;
P2OUT&=~SCLK; //SCLK=0; P2OUT|=SCLK; //SCLK=1; i_data=i_data<<1;
switch(x) {
case 1:pos=0x80+y;break; case 2:pos=0x90+y;break; case 3:pos=0x88+y;break; case 4:pos=0x98+y;break; }
20
}
void LCD_12864(uchar x,uchar y,char *q)//在x行y列显示字符串q { uchar i;
__delay_cycles(10); }
void send(uchar x,uchar y,int date)//在x行y列显示字符串q {
__delay_cycles(10); } void adc() { }
void anjian() {
P2DIR&=~BIT3; P2OUT|=BIT3; P2DIR&=~BIT4; P2OUT|=BIT4; P2DIR&=~BIT5; P2OUT|=BIT5; P1DIR&=~BIT7; P1OUT|=BIT7;
21
Write_Cmd(pos);
pos(x,y);
for(i=0;*(q+i)!='\\0';i++)
Write_Data(q[i]);
pos(x,y); Write_Data(date);
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start __bis_SR_register(CPUOFF + GIE); ad=ADC10MEM; date=ADC10MEM;
a1=((double)date/1023)*3.64;
// LPM0, ADC10_ISR will force exit
}
{
{
}
i=i-10; if(i==90)
i=0; {
LCD_12864(3,0,\转换电压:\
send(4,2,(int)a1/10000+0x30); send(4,3,(int)a1000/1000+0x30); send(4,4,(int)a100/100+0x30); send(4,5,(int)a10/10+0x30); send(4,6,(int)a1+0x30); LCD_12864(4,7,\
LCD_12864(1,0,\转换电流:\ send(2,2,i/1000+0x30); send(2,3,i/100+0x30); send(2,4,i/10+0x30); send(2,5,i+0x30);
while(!(P2IN&BIT4)); Write_Cmd(0x01);
if(!(P2IN&BIT4))
{
{
__delay_cycles(1000);
if(!(P2IN&BIT4))
//while((P2IN&BIT3)&&(P2IN&BIT5)&&(P1IN&BIT6))
LCD_12864(2,7,\ __delay_cycles(1000); }
if(!(P2IN&BIT3))
__delay_cycles(1000);
if(!(P2IN&BIT3))
Write_Cmd(0x01); while(!(P2IN&BIT3));
LCD_12864(1,0,\进入设置界面\
22
}
if(!(P1IN&BIT7)){
__delay_cycles(1000); if(!(P1IN&BIT7)) {
while(!(P1IN&BIT7)); Write_Cmd(0x01);
//while((P1IN&BIT7)&&(P1IN&BIT7))
{
LCD_12864(3,0,\输入电流监测:\ send(4,2,(int)a1+0x30); send(4,3,0x2e);
send(4,4,(int)(a1*10)+0x30);
23
}
LCD_12864(2,0,\按2---电流\ LCD_12864(3,0,\按4---\ LCD_12864(4,0,\负载调整率\ __delay_cycles(1000); } {
if(!(P2IN&BIT5))
__delay_cycles(1000); if(!(P2IN&BIT5)) { }
while(!(P2IN&BIT5)); Write_Cmd(0x01);
//while((P2IN&BIT4)&&(P2IN&BIT3))
LCD_12864(3,0,\输入电流监测:\ send(4,2,(int)a1+0x30); send(4,3,0x2e);
send(4,4,(int)(a1*10)+0x30); send(4,5,(int)(a1*100)+0x30); send(4,6,(int)(a1*1000)+0x30); LCD_12864(4,7,\
send(4,5,(int)(a1*100)+0x30); send(4,6,(int)(a1*1000)+0x30); LCD_12864(4,7,\
LCD_12864(1,0,\取样电阻5R\ Write_A_B(1, 2, Channal_AB, 1); }
/////////////////////////ADS1115///////////////////////////////////// void delay(void) {
uchar i; }
/******************************************* 函数名称:start
功 能:完成IIC的起始条件操作 参 数:无 返回值 :无
********************************************/ void start(void) { }
/******************************************* 函数名称:stop
功 能:完成IIC的终止条件操作
24
}
}
}
for(i = 0;i < 15;i++) _NOP();
SCL_H; SDA_H; delay(); SDA_L; delay(); SCL_L; delay();