📄 test.i
字号:
#line 55 "C:\PROGRA~1\iccv7avr\include\macros.h"
void _StackCheck(void);
void _StackOverflowed(char);
#line 5 "D:\iccavr\mega16\11\max144\delay.h"
void delay_us(void)
{
asm("nop");
}
void delay_nus(unsigned int t)
{
while(t--)
delay_us();
}
void delay_ms(void)
{
unsigned int i;
for(i=0;i<1140;i++);
}
void delay_nms(unsigned int t)
{
while(t--)
delay_ms();
}
#line 22 "D:\iccavr\mega16\11\max144\lcd1602.h"
void LCD_init (void);
void LCD_en_write (void);
void clear(void);
void LCD_write_char(unsigned command,unsigned data);
void LCD_set_xy(unsigned char x, unsigned char y);
void LCD_init(void)
{
(*(volatile unsigned char *)0x34)|=0xf0;
(*(volatile unsigned char *)0x34)|=0x08;
(*(volatile unsigned char *)0x34)|=0x04;
delay_nms(15);
LCD_write_char(0x28,0);
delay_nms(15);
LCD_write_char(0x0c,0);
delay_nms(15);
LCD_write_char(0x01,0);
clear();
}
void LCD_set_xy(unsigned char x, unsigned char y)
{
unsigned char address;
if(y ==0)
address=0x80+x;
else
address=0xc0+x;
LCD_write_char(address,0);
}
void LCD_en_write(void)
{
(*(volatile unsigned char *)0x35)|=0x08;
delay_nus(5);
(*(volatile unsigned char *)0x35)&=~0x08;
}
void LCD_write_char(unsigned command,unsigned data)
{
unsigned command_temp,data_temp;
command_temp=command;
data_temp=data;
delay_nus(25);
if(command==0)
{
(*(volatile unsigned char *)0x35)|=0x04;
(*(volatile unsigned char *)0x35)&=0X0f;
(*(volatile unsigned char *)0x35)|=data_temp&0xf0;
LCD_en_write();
data_temp=data_temp<<4;
(*(volatile unsigned char *)0x35)&=0X0f;
(*(volatile unsigned char *)0x35)|=data_temp&0xf0;
LCD_en_write();
}
else
{
(*(volatile unsigned char *)0x35)&=~0x04;
(*(volatile unsigned char *)0x35)&=0X0f;
(*(volatile unsigned char *)0x35)|=command_temp&0xf0;
LCD_en_write();
command_temp=command_temp<<4;
(*(volatile unsigned char *)0x35)&=0x0f;
(*(volatile unsigned char *)0x35)|=command_temp&0xf0;
LCD_en_write();
}
}
void clear(void)
{
unsigned char i;
LCD_set_xy(0,0);
for(i=0;i<16;i++)
LCD_write_char(0,' ');
LCD_set_xy(0,1);
for(i=0;i<16;i++)
LCD_write_char(0,' ');
}
void LCD_write_string(unsigned char X,unsigned char Y,unsigned char *s)
{
LCD_set_xy(X,Y);
while(*s)
{
LCD_write_char(0,*s);
s++;
}
}
void LCD_write_data(unsigned char X,unsigned char Y,int dat)
{
unsigned char fuhao;
unsigned char data[5];
unsigned char i;
if(dat<0)
{
fuhao='-';
dat=0-dat;
}
else
fuhao=' ';
data[0]=fuhao;
data[1]=dat/1000+0x30; dat%=1000;
data[2]=dat/100+0x30; dat%=100;
data[3]=dat/10+0x30;
data[4]=dat%10+0x30;
LCD_set_xy(X,Y);
for(i=0;i<5;i++)
LCD_write_char(0,data[i]);
}
#line 9 "D:\iccavr\mega16\11\max144\max144.h"
unsigned int adc_out1,adc_out0;
unsigned int adcttemp[2][15];
unsigned int adcfirst[2];
void max144_read(void)
{
unsigned char temp;
unsigned int adc_temp=0;
unsigned long adc;
(*(volatile unsigned char *)0x3B)|=(1 << (5))|(1 << (6))|(1 << (7));
(*(volatile unsigned char *)0x3A)|=(1 << (5))|(1 << (7));
(*(volatile unsigned char *)0x3A)&=~(1 << (6));
(*(volatile unsigned char *)0x3B)|=(1 << (5));
(*(volatile unsigned char *)0x3B)|=(1 << (7));
(*(volatile unsigned char *)0x3B)&=~(1 << (5));
asm("nop");asm("nop");asm("nop");asm("nop");
(*(volatile unsigned char *)0x3B)&=~(1 << (7));
while(1)
{
if(((*(volatile unsigned char *)0x39)&(1 << (6)))==(1 << (6)))
break;
}
temp=16; while(temp--)
{
(*(volatile unsigned char *)0x3B)|=(1 << (7));
if(((*(volatile unsigned char *)0x39)&(1 << (6)))==(1 << (6)))
adc_temp++;
adc_temp=adc_temp<<1;
(*(volatile unsigned char *)0x3B)&=~(1 << (7));
}
(*(volatile unsigned char *)0x3B)|=(1 << (5));
if((adc_temp&0x2000)==0x2000)
{
adcfirst[0]=(adc_temp>>1)&0xfff;
adc_temp&=0x1ffc;
adc=adc_temp;
adcttemp[0][14]=adc_temp;
for(temp=0;temp<14;temp++)
{
adcttemp[0][temp]=adcttemp[0][temp+1];
adc+=adcttemp[0][temp];
}
adc/=15;
adc_temp=adc;
adc_out1=adc>>1;
}
else
{
adcfirst[1]=(adc_temp>>1)&0xfff;
adc_temp&=0x1ffc;
adc=adc_temp;
adcttemp[1][14]=adc_temp;
for(temp=0;temp<14;temp++)
{
adcttemp[1][temp]=adcttemp[1][temp+1];
adc+=adcttemp[1][temp];
}
adc/=15;
adc_temp=adc;
adc_out0=adc>>1;
}
}
#line 13 "D:\iccavr\mega16\11\max144\test.c"
void mcu_init(void)
{
LCD_init();
}
void main(void)
{
mcu_init();
LCD_write_string(0,0," MAX144 TEST ");
while(1)
{
max144_read();
LCD_write_data(0,1,adc_out1);
}
}
[Compiler Options]
Edit1=
Edit2=
Edit8=
CheckBox1=0
CheckBox2=1
Edit3=
Edit4=
Edit11=16
Edit13=
ComboBox1=0
Edit9=16384
Edit10=1024
ComboBox2=18
RadioGroup1=0
Edit15=
CheckBox6=0
Edit12=0x2A
CheckBox7=1
CheckBox8=1
RadioGroup2=0
Edit5=
Edit6=
ComboBox3=-1
Edit14=
Edit17=
Edit7=
CheckBox3=0
Edit16=
Edit18=0x60
CheckBox4=0
CheckBox5=1
ComboBox4=0
CheckBox9=0
Edit19=
Edit20=512
Edit21=0
DeviceString=1
Edit23=
CheckBox13=0
Edit24=7.13
Edit25=
RadioGroup3=0
ComboBox10=0
ComboBox9=0
RadioGroup6=0
Edit27=
CheckBox17=0
CheckBox18=0
RadioGroup8=2
CheckBox11=0
Edit22=0.0x1FFFF
CheckBox12=0
SalvoRadioGroup=6
RadioGroup9=0
SalvoPathEdit=
CheckBox16=0
ComboBox5=-1
Edit26=5
Edit28=
Edit29=
Edit30=
Edit31=
RadioGroup7=0
Edit33=40
Edit34=100
Edit32=
CheckBox19=0
CheckBox20=0
Edit37=
CheckBox21=0
CheckBox15=0
EditFillBytes=
CheckBox22=0
CheckBox10=0
ChangeState=0
CheckBox23=0
CheckBox24=0
RadioGroup4=2
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -