⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 out_rej_displey.i

📁 Example the project test UART for AVR161 on C for IAR
💻 I
字号:













sfrb UBRR1 = 0x00;

sfrb UCSR1B = 0x01; 

sfrb UCSR1A = 0x02; 

sfrb UDR1 = 0x03;

sfrb PINE = 0x05;

sfrb DDRE = 0x06; 

sfrb PORTE = 0x07; 

sfrb ACSR = 0x08; 

sfrb UBRR0 = 0x09; 

sfrb UCSR0B = 0x0A; 

sfrb UCSR0A = 0x0B; 

sfrb UDR0 = 0x0C; 

sfrb SPCR = 0x0D; 

sfrb SPSR = 0x0E; 

sfrb SPDR = 0x0F; 

sfrb PIND = 0x10; 

sfrb DDRD = 0x11; 

sfrb PORTD = 0x12; 

sfrb PINC = 0x13; 

sfrb DDRC = 0x14; 

sfrb PORTC = 0x15; 

sfrb PINB = 0x16; 

sfrb DDRB = 0x17; 

sfrb PORTB = 0x18; 

sfrb PINA = 0x19; 

sfrb DDRA = 0x1A; 

sfrb PORTA = 0x1B; 

sfrb EECR = 0x1C; 

sfrb EEDR = 0x1D; 

sfrw EEAR = 0x1E; 
sfrb EEARL = 0x1E; 
sfrb EEARH = 0x1F; 

sfrb UBRRHI = 0x20; 

sfrb WDTCR = 0x21; 

sfrb OCR2 = 0x22; 

sfrb TCNT2 = 0x23; 

sfrw ICR1 = 0x24; 
sfrb ICR1L = 0x24; 
sfrb ICR1H = 0x25; 

sfrb ASSR = 0x26; 

sfrb TCCR2 = 0x27; 

sfrw OCR1B = 0x28; 
sfrb OCR1BL = 0x28; 
sfrb OCR1BH = 0x29; 

sfrw OCR1A = 0x2A; 
sfrb OCR1AL = 0x2A; 
sfrb OCR1AH = 0x2B; 

sfrw TCNT1 = 0x2C; 
sfrb TCNT1L = 0x2C; 
sfrb TCNT1H = 0x2D; 

sfrb TCCR1B = 0x2E; 

sfrb TCCR1A = 0x2F; 

sfrb SFIOR = 0x30; 

sfrb OSCCAL = 0x31;


sfrb TCNT0 = 0x32; 

sfrb TCCR0 = 0x33; 

sfrb MCUSR = 0x34; 

sfrb MCUCR = 0x35; 

sfrb EMCUCR = 0x36; 

sfrb SPMCR = 0x37; 

sfrb TIFR = 0x38; 

sfrb TIMSK = 0x39; 

sfrb GIFR = 0x3A; 

sfrb GIMSK = 0x3B; 

sfrw SP = 0x3D; 
sfrb SPL = 0x3D; 
sfrb SPH = 0x3E; 

sfrb SREG = 0x3F; 























void _SEI(void);
void _CLI(void);
void _NOP(void);
void _SLEEP(void);

unsigned char _LPM(unsigned short val);

unsigned char _ELPM(unsigned long val);

void _WDR(void);

void _OPC(unsigned short op);


























extern unsigned int flagi; 









































enum {koeff1, koeff2, koeff3, time_zasl, time_test, time_puskat, 
time_osv_zagr,time_mixer, time_zvuk_pred, time_zvuk_alarm, time_clr_razgr, time_dosipan, 
delta_tara,rezerv1,rezerv2,rezerv3,ccr, 
zad_ves, tara, ves_old, ves_delta,count_tek_comp, 
kan1, kan2,kan3,tek_ves, tek_ves_old}; 


enum {rej0,rej1,start,statist,slujeb_const,slujeb_var,error_crc};

void PUT_PAGE(void);
void obr_knopok(void);
void opr_knopok(void);
void acp_on_CH(unsigned char);
void delay(int ticks);
void out_acp(void);
void gotoz(unsigned char z);
void initgraph(void);
void sprint_long(long int var); 
void sprint_int(unsigned int var); 
void outtext(char* text);
void SUMMA_PROC(void);
void page_work(void);
void page_statstika(void);
void page_reji(void);
void page_slujebniy(void);
void page_edit_procent(void); 
void ptchar(char c); 
void RASCHET_PROCENT_MASSA_ZAD_VES(void);
void RASCHET_NAMBER_VAR(void);
void KORREKT_VAR(void);
void save_eeprom(void);
unsigned char coder(unsigned char data);
void page_sluj_const(void); 
void eerd_all (void);
void eewr_all (void);
void CIKL (void); 
void RASCHET_PROCENT_MASSA_ZAD_VES(void); 
void EECLR ( void);
void SRAMCLR ( void); 
void ves (void); 
void zvonok_alarm(void); 
void rejim1(void);
void START_PART(void);
void stop (void); 
void test_mex_vkl (void);
void test_mex_otkl (void);
void SUMM_STAT_KOMP(void);
void SUMM_STAT_KOMP_CLR(void);
void simulator(void);
void eewr_zad_part(void); 
void clrscr(void); 
void clr_tek_mass(void);
int test_rost_razgr(void);
void lcd_send(unsigned char data);
char rcom_byte(char Add); 
void vich_delta(void);


extern struct {int procent, massa, tek_massa,delta;}KOMPONENT[6];
extern unsigned int stat_komp[6];
extern unsigned char addr_str; 
extern unsigned char addr_str_sluj; 
extern unsigned char namber_str;
extern unsigned char namber_str_stat; 
extern unsigned char namber_rej;
extern char namber_var;
extern unsigned char kursor; 
extern unsigned char kursor_rej; 
extern unsigned char kursor_sluj; 
extern unsigned char kursor_sl_const; 
extern unsigned char buf_dec[8]; 
extern unsigned char slu; 
extern long int zad_part;
extern long int add_summ_comp;
extern int adr_start;
extern unsigned int n[tek_ves_old+1];
extern long int tek_part; 
extern unsigned int temp_int;




unsigned char buff_disp[16];
unsigned int summa_procent;
unsigned int adr_const;
unsigned char temp;
unsigned char text1[]= {'N',' ',' ',' ','c',0x79,0xbc,0xbc,'a',' ',0xba,0xb4,' ',' ',' ',' '}; 
unsigned char text2[]= {'N',' ',' ','%',' ',' ',' ','k',0xb4,' ',' ',' ','%','+',' ',' '}; 
unsigned char text3[]= {'c',0xb2,'p','o','c',' ','p','a','c','x','o',0xe3,'a',' ','-',' '};
unsigned char text4[]= {0xbd,'a',0xb6,'a',0xbf,0xc4,' ','2',' ',0xba,0xbd,'o',0xbe,0xba,0xb8,':'};
unsigned char text5[]= {' ',' ',' ','"','+','"',' ',0xb8,' ','"','-','"',' ',' ',' ',' '};
unsigned char text6[]= {'c',0xb2,'o',0xb9,' ',0xbe,'o',' ',0xbe,0xb8,0xbf,'a',0xbd,0xb8,0xc6,'!'};
unsigned char text7[]= {' ',' ','B','o','c','c',0xbf,'a',0xbd,'o',0xb3,0xb8,0xbf,0xc4,' ',' '};
unsigned char text8[]= {' ',' ',' ',0xbd,'a','c',0xbf,'p','o',0xb9,'k',0xb8,'!','!','!',' ',};






void page_error_crc(void){
char i;
gotoz ( 0x80 ); 
outtext(text6);
gotoz ( 0xC0 ); 
for(i=0;i<16;i++) ptchar(' '); 
gotoz ( 0x90 ); 
outtext(text7); 
gotoz ( 0xD0 ); 
outtext(text8); 

}

void out_buff9_13(long int a){ 
sprint_long(a); 
buff_disp[9]='0'+buf_dec[3];
buff_disp[10]='0'+buf_dec[4];
buff_disp[11]='0'+buf_dec[5];
buff_disp[12]='0'+buf_dec[6];
buff_disp[13]='0'+buf_dec[7];
}

void out_buff10_13( int a){ 
sprint_int(a); 
buff_disp[10]='0'+buf_dec[2];
buff_disp[11]='0'+buf_dec[3];
buff_disp[12]='0'+buf_dec[4];
buff_disp[13]='0'+buf_dec[5];
}

void OUT_STR_REJ(void){ 
switch (temp){ 
case 0:{
buff_disp[0]=(0xB7); 
buff_disp[1]=('a'); 
buff_disp[2]=(0xE3); 
buff_disp[3]=(' '); 
buff_disp[4]=(0xBE); 
buff_disp[5]=('o'); 
buff_disp[6]=('p'); 
buff_disp[7]=(0xe5); 
buff_disp[8]=(' '); 
out_buff9_13(zad_part);
buff_disp[14]=('k'); 
buff_disp[15]=(0xb4); 
} 
break;
case 1:{
buff_disp[0]=(0xBF); 
buff_disp[1]=('e'); 
buff_disp[2]=('k'); 
buff_disp[3]=(' '); 
buff_disp[4]=(0xBE); 
buff_disp[5]=('o'); 
buff_disp[6]=('p'); 
buff_disp[7]=(0xe5); 
buff_disp[8]=(' '); 
out_buff9_13(tek_part);
buff_disp[14]=('k'); 
buff_disp[15]=(0xb4); 
} 
break;
case 2:{
buff_disp[0]=(0xB7); 
buff_disp[1]=('a'); 
buff_disp[2]=(0xE3); 
buff_disp[3]=(' '); 
buff_disp[4]=(0xb3); 
buff_disp[5]=('e'); 
buff_disp[6]=('c'); 
buff_disp[7]=(' '); 
buff_disp[8]=(' '); 
buff_disp[9]=(' '); 
out_buff10_13(n[zad_ves]);
buff_disp[14]=('k'); 
buff_disp[15]=(0xb4); 
}
break;
case 3:{
buff_disp[0]=(0xbf); 
buff_disp[1]=('e'); 
buff_disp[2]=('k'); 
buff_disp[3]=(0x79); 
buff_disp[4]=(0xe6); 
buff_disp[5]=(' '); 
buff_disp[6]=(0xb3); 
buff_disp[7]=('e'); 
buff_disp[8]=('c'); 
buff_disp[9]=(' '); 
if(n[tara]>n[tek_ves]) out_buff10_13(0);
else out_buff10_13(n[tek_ves]-n[tara]);

buff_disp[14]=('k'); 
buff_disp[15]=(0xb4); 
} 
break;
default: ;
}
}
void OUT_STR_PROCENT(void){ 
int a;
a=KOMPONENT[temp].procent;
sprint_int(a); 
buff_disp[0]='0'+temp+1;
buff_disp[1]=' ';
buff_disp[2]='0'+buf_dec[3];
if(buff_disp[2]=='0') buff_disp[2]=' '; 
buff_disp[3]='0'+buf_dec[4];
buff_disp[4]=',';
buff_disp[5]='0'+buf_dec[5];
buff_disp[6]=' ';
a=KOMPONENT[temp].massa;
sprint_int(a); 
buff_disp[7]='0'+buf_dec[3];
if(buff_disp[7]=='0') buff_disp[7]=' '; 
buff_disp[8]='0'+buf_dec[4];
if(buff_disp[7]==' '){ 
if(buff_disp[8]=='0') buff_disp[8]=' ';
} 
buff_disp[9]='0'+buf_dec[5];
if ( (!(flagi & 0x0001 )) ){
buff_disp[10]=' ';
buff_disp[11]=' ';
buff_disp[12]=' ';
buff_disp[13]=' ';
buff_disp[14]=' ';
buff_disp[15]=' ';
if(temp==0 || temp==3 || temp==6){
sprint_int(summa_procent); 
buff_disp[11]='0'+buf_dec[2];
if(buff_disp[11]=='0') buff_disp[11]=' '; 
buff_disp[12]='0'+buf_dec[3];
if(buff_disp[11]==' '){ 
if(buff_disp[12]=='0') buff_disp[12]=' ';
} 
buff_disp[13]='0'+buf_dec[4];
buff_disp[14]=',';
buff_disp[15]='0'+buf_dec[5];
} 
if(temp==1 || temp==4 || temp==7){
if(summa_procent>1000){
buff_disp[11]=0xbc;
buff_disp[12]=0xbd;
buff_disp[13]='o';
buff_disp[14]=0xb4;
buff_disp[15]='o'; 
} 
if(summa_procent==1000){
buff_disp[11]=0xbd;
buff_disp[12]='o';
buff_disp[13]='p';
buff_disp[14]=0xbc;
buff_disp[15]='a'; 
} 
if(summa_procent<1000){
buff_disp[11]=' ';
buff_disp[12]=0xbc;
buff_disp[13]='a';
buff_disp[14]=0xbb;
buff_disp[15]='o'; 
} 
} 
}
else {
sprint_int(KOMPONENT[temp].tek_massa); 
buff_disp[10]=' ';
buff_disp[11]='0'+buf_dec[3];
if(buff_disp[11]=='0') buff_disp[11]=' '; 
buff_disp[12]='0'+buf_dec[4];
if(buff_disp[11]==' '){ 
if(buff_disp[12]=='0') buff_disp[12]=' ';
} 
buff_disp[13]='0'+buf_dec[5];
buff_disp[14]=' ';
buff_disp[15]=' ';
} 
} 

void page_rejim1(void){
temp=0;
OUT_STR_REJ();
gotoz ( 0x80 ); 
outtext(buff_disp);
temp++;
OUT_STR_REJ();
gotoz ( 0xC0 ); 
outtext(buff_disp);
temp++;
OUT_STR_REJ();
gotoz ( 0x90 ); 
outtext(buff_disp);
temp++;
OUT_STR_REJ();
gotoz ( 0xD0 ); 
outtext(buff_disp);
gotoz( 0x80 +kursor_rej);
}

void page_start_cikl(void){
if(n[count_tek_comp]>3) temp=3; 
else temp=0;

gotoz ( 0x80 ); 
outtext(text2); 
gotoz ( 0x80 +11); 
ptchar('k'); 
ptchar(0xb4); 
ptchar('+'); 
OUT_STR_PROCENT();
gotoz ( 0xC0 ); 
outtext(buff_disp);
temp++;
OUT_STR_PROCENT();
gotoz ( 0x90 ); 
outtext(buff_disp);
temp++;
OUT_STR_PROCENT();
gotoz ( 0xD0 ); 
outtext(buff_disp);
switch (n[count_tek_comp]){ 
case 1: temp= 0xC0 ; 
break;
case 2: temp= 0x90 ;
break;
case 3: temp= 0xD0 ;
break;
case 4: temp= 0xC0 ;
break;
case 5: temp= 0x90 ;
break;
case 6: temp= 0xD0 ;
break;
case 7: temp= 0xD0 ;
break;
default: temp= 0xC0 ; 
} 
gotoz (temp+15); 
ptchar('*'); 
gotoz (temp+15); 
}

void OUT_ADD_SUMMA(void){ 
add_summ_comp=0;
SUMM_STAT_KOMP();
sprint_long(add_summ_comp); 
buff_disp[0]=0xb8;
buff_disp[1]=0xbf;
buff_disp[2]='o';
buff_disp[3]=0xb4;
buff_disp[4]='o' ;
buff_disp[5]=':' ;
buff_disp[6]=' ';
buff_disp[7]=' ';
buff_disp[8]='0'+buf_dec[2];
buff_disp[9]='0'+buf_dec[3];
buff_disp[10]='0'+buf_dec[4];
buff_disp[11]='0'+buf_dec[5];
buff_disp[12]='0'+buf_dec[6];
buff_disp[13]='0'+buf_dec[7];
buff_disp[14]=' ';
buff_disp[15]=' ';
}
void OUT_STR_STAT(void){
sprint_int(stat_komp[temp]); 
buff_disp[0]='0'+temp+1;
buff_disp[1]=' ';
buff_disp[2]=' ';
buff_disp[3]=' ';
buff_disp[4]='0'+buf_dec[1];
buff_disp[5]='0'+buf_dec[2];
buff_disp[6]='0'+buf_dec[3];
buff_disp[7]='0'+buf_dec[4];
buff_disp[8]='0'+buf_dec[5];
buff_disp[9]=' ';
buff_disp[10]=' ';
buff_disp[11]=' ';
buff_disp[12]=' ';
buff_disp[13]=' ';
buff_disp[14]=' ';
buff_disp[15]=' ';
}
void page_statistika(void){ 
switch (namber_str_stat){ 
case 0: temp=0;
break;
case 1: temp=3;
break;
case 2: temp=6;
break;
default: ;
} 
if(namber_str_stat>1){
OUT_ADD_SUMMA();
gotoz ( 0x80 ); 
outtext(buff_disp);
gotoz ( 0xC0 ); 
outtext(text3); 
gotoz ( 0x90 ); 
outtext(text4); 
gotoz ( 0xD0 ); 
outtext(text5); 
}
else{
gotoz ( 0x80 ); 
outtext(text1); 
OUT_STR_STAT();
gotoz ( 0xC0 ); 
outtext(buff_disp);
temp++;
OUT_STR_STAT();
gotoz ( 0x90 ); 
outtext(buff_disp);
temp++;
OUT_STR_STAT();
gotoz ( 0xD0 ); 
outtext(buff_disp);
}
gotoz ( 0xD0 ); 
}

void page_rejim0(void){ 
if  (!(flagi & 0x0001 )) {
switch (namber_str){ 
case 0: temp=0;
break;
case 1: temp=0;
break;
case 2: temp=0;
break;
case 3: temp=3;
break;
case 4: temp=3;
break;
case 5: temp=3;
break;
default: temp=6;
} 
gotoz ( 0x80 ); 
outtext(text2); 
OUT_STR_PROCENT();
gotoz ( 0xC0 ); 
outtext(buff_disp);
temp++;
OUT_STR_PROCENT();
gotoz ( 0x90 ); 
outtext(buff_disp);
temp++;
OUT_STR_PROCENT();
gotoz ( 0xD0 ); 
outtext(buff_disp);
gotoz(addr_str+kursor); 
}
else page_start_cikl(); 
}

void OUT_VARIABLE(void){
sprint_int(n[temp]); 
buff_disp[0]='0'+(temp+1);
buff_disp[1]=' ';
buff_disp[2]='0'+buf_dec[1];
buff_disp[3]='0'+buf_dec[2];
buff_disp[4]='0'+buf_dec[3];
buff_disp[5]='0'+buf_dec[4];
buff_disp[6]='0'+buf_dec[5];
buff_disp[7]=' ';
temp++;
sprint_int(n[temp]); 
buff_disp[8]='0'+temp+1;
buff_disp[9]=' ';
buff_disp[10]='0'+buf_dec[1];
buff_disp[11]='0'+buf_dec[2];
buff_disp[12]='0'+buf_dec[3];
buff_disp[13]='0'+buf_dec[4];
buff_disp[14]='0'+buf_dec[5];
buff_disp[15]=' ';
temp++;
}
void outstr_disp(unsigned int adr) {
char *dis=buff_disp; 
char i; 
char *dec=buf_dec+1; 
char *dec1=buf_dec+3; 
char *dec2=buf_dec+3; 
unsigned int *s=(unsigned int *)(adr+80); 
sprint_int(adr+80); 
for(i=0;i<3;i++) *dis++='0'+*dec2++;
*dis=' ';
*dis++;
sprint_int((char)*s); 
for(i=0;i<3;i++) *dis++='0'+*dec1++;
*dis=' ';
*dis++;
sprint_int((unsigned int)*s); 
for(i=0;i<5;i++) *dis++='0'+*dec++;
*dis=' ';
*dis++=' ';
*dis++=' ';
}
void page_sluj_const(void){ 
adr_const=adr_start;
gotoz ( 0x80 ); 
outstr_disp(adr_const);
outtext(buff_disp);
adr_const++;
gotoz ( 0xC0 ); 
outstr_disp(adr_const);
outtext(buff_disp);
adr_const++;
gotoz ( 0x90 ); 
outstr_disp(adr_const);
outtext(buff_disp);
adr_const++;
gotoz ( 0xD0 ); 
outstr_disp(adr_const);
outtext(buff_disp);
gotoz ( 0x80 +kursor_sl_const); 
}
void page_sluj_var(void){
temp=0;
if(namber_var>7) temp=8; 
if(namber_var>15) temp=16; 
OUT_VARIABLE();
gotoz ( 0x80 ); 
outtext(buff_disp);
OUT_VARIABLE();
gotoz ( 0xC0 ); 
outtext(buff_disp);
OUT_VARIABLE();
gotoz ( 0x90 ); 
outtext(buff_disp);
OUT_VARIABLE();
gotoz ( 0xD0 ); 
outtext(buff_disp);

if(namber_var<8) temp=(namber_var+2)/2; 
else{
if(namber_var>15) temp=(namber_var-14)/2;
else{
temp=(namber_var-6)/2;
}
} 
switch (temp){ 
case 1: addr_str_sluj= 0x80 ;
break;
case 2: addr_str_sluj= 0xC0 ;
break;
case 3: addr_str_sluj= 0x90 ;
break;
case 4: addr_str_sluj= 0xD0 ;
break;
default: ;
} 
gotoz (addr_str_sluj+kursor_sluj);
} 

void page_slujebnniy(void){

}


void PUT_PAGE(void){
DDRD |= ( (1 << 4)  |  (1 << 6)  |  (1 << 5) );
 (PORTD &= ~ (1 << 6) ) ;
 (PORTD &= ~ (1 << 5) ) ;




lcd_send(0x02);
ves ();
if  (( PINB ) & (1<<( 0 )) ) { 
switch (namber_rej){
case rej0: page_rejim0();
break;
case rej1: page_rejim1();
break;
case statist: page_statistika();
break;
case error_crc: page_error_crc();
break;
default: page_rejim0(); 
}
}
else 
switch (slu){
case slujeb_var: page_sluj_var();
break;
case slujeb_const:page_sluj_const();
break;
default: page_sluj_var(); 
}
} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -