Устройство измерения температуры окружающей среды, напряжения на выходах потенциометра, управление звуковым излучателем и часы
Курсовой проект - Компьютеры, программирование
Другие курсовые по предмету Компьютеры, программирование
_asm sublw0x00 _endasm
} while (STATUSbits.Z==0);(SSPSTATbits.R_W==1) {};
}
void start (void)
{();=0b10100100; //initialize USART=25;=0b10010000;
.TRISC2=0; //CCP=0x80;L=0x80;CONbits.CCP1X=0;CONbits.CCP1Y=0;
CON=0x05;
.TRISA4=1;.TRISB0=1;
}main(void)
{_wr=0;_count=16;();();
}
menu(void)
{_count=16;_pos=5;_char_1();_pos=6;_char_2();KTCYx(900);(scroll==0){};(select==0){};
//------------------ VOLT MEASUREMENT ----------------------------(1){
ptr_pos=0;
stan_char_1();_pos=4;_char_2();(scroll==1) {if (select==0) {voltmeter();break;}} ;(select==0){};while (scroll==0){};
//------------------ BUZZER --------------------------------------(select==0){};_pos=1;_char_1();_pos=4;_char_2();
(scroll==1) {if (select==0) {buzzer();break;}} ;(select==0){};while (scroll==0){};
//----------------- TEMPERATURE MEASUREMENT ----------------------(select==0){};_pos=2;_char_1();_pos=4;_char_2();(scroll==1) {if (select==0) {temp();break;}};(select==0){};while (scroll==0){};
//------------------ CLOCK TIME ----------------------------------(select==0){};_pos=3;_char_1();_pos=4;_char_2();
(scroll==1) {if (select==0) {clock();break;}};(select==0){};while (scroll==0){};
};
}
//************* STANDARD USER CODE **********************************
//------------- Voltmeter--------------------------------------------voltmeter(void)
{
int i;temp_char;(select==0){};
bits.ADON=1;=0b00001110;=0x01;
_pos=10;_char_1();
{bits.GO=1;(ADCON0bits.GO==0){};=ADRESH;*=2;(temph,tempv_char);(temph<10)
{temph_char[0]=zero[0];temph_char[2]=zero[0];temph_char[3]=tempv_char[0];}if (temph<100)
{temph_char[0]=zero[0];temph_char[2]=tempv_char[0];temph_char[3]=tempv_char[1];} //10<=x<100{temph_char[0]=tempv_char[0];temph_char[2]=tempv_char[1];temph_char[3]=tempv_char[2];} //10<=x<100
_2();(i=0;i<ptr_count;i++)
{_char=temph_char[i];_wr=temp_char;_write();
} //for i
}while(select==1);
}
//--------------------- BUZZER --------------------------------------buzzer(void)
{temp_char;
int n,i;
while(select==0){};=0x80;L=0x80;
_1();_pos=11;_char_1();_2();_pos=8;_char_2();CON=0x0f;(1){=0;(select==0)
{+=1;=5;=PR2;
(scroll==0)end;
} //if select(scroll==0)
{//inc dcL+=1;=CCPR1L;=12;(select==0)end;
}(n!=0) {(temph,tempv_char);
(temph<10)
{tempb_char[n]=zero[0];tempb_char[n+1]=zero[0];tempb_char[n+2]=tempv
_char[0];}if (temph<100)
{tempb_char[n]=zero[0];tempb_char[n+1]=tempv_char[0];tempb_char[n+2]=tempv_char[1];} //10<=x<100
{tempb_char[n]=tempv_char[0];tempb_char[n+1]=tempv_char[1];tempb_char[n+2]=tempv_char[2];} //10<=x<100
_1();(i=0;i<ptr_count;i++)
{_char=tempb_char[i];_wr=temp_char;_write();
} //for i
} //if n!=0
};//while:CCP1CON=0;
}
//---------------------- Temperature --------------------------------temp (void)
{tempw,temp_char;i;(select==0){};.TRISC3=1; //initialize MSSP module.TRISC4=1;=0b00101000;.SMP=1;=0x05;
bits.TMR1IF=0;//load Timer1 for 2 sec overflowH=0;L=0;{
//GET_TEMP_temp:cmd_byte=0x01; //config register command byte
//TEMP_NOW_now:SSPSTATbits.CKE=1; //SMBUS spec for TC74
bits.SEN=1;//write to TC74(SSPCON2bits.SEN==1){};=0b10011010;//send TC74 ADDRESS (write)
ssprw();
while (SSPCON2bits.ACKSTAT==1) {};//ack?
=cmd_byte;=WREG;//send COMMAND byte (config)();(SSPCON2bits.ACKSTAT==1) {};//ack?
bits.RSEN=1;//send repeated start(SSPCON2bits.RSEN==1) {};=0b10011011;//send TC74 ADDRESS (read)();//module idle?(SSPCON2bits.ACKSTAT==1) {};//ack?
bits.RCEN=1;//enable receive mode(SSPCON2bits.RCEN==1) {};
=SSPBUF; //retrieve config reg or temp reg
bits.ACKDT=1;//send NOT-ACKbits.ACKEN=1;(SSPCON2bits.ACKEN==1){};
bits.PEN=1; //stop(SSPCON2bits.PEN==1){};=WREG;(cmd_byte==1) { //config command OR temp command=tempw;
_asm0x40//is temp ready ??0x40
_endasm(STATUSbits.Z==0) {goto get_temp;}_byte=0x00;temp_now;
}
=tempw;(temperature,tempv_char);_char[6]=tempv_char[0];tempt_char[7]=tempv_char[1];_1();(i=0;i<ptr_count;i++)
{_char=tempt_char[i];_wr=temp_char;_write();
} //for i_2();_pos=9;_char_2();
}while(select==1);
}
//----------------- CLOCK ------------------------------------------clock (void)
{temp_char;i,n;(select==0){};
CON=0x0F;=0;minutes=0;hours=0;{bits.TMR1IF=0;H=0x68;L=0x00;
++;(seconds-60==0) {++;=0;
}(minutes-60==0){++;=0;
}(hours-13==0){=0;
}(scroll==0) clock_set();
clock_draw();
_2();
ptr_pos=7;_char_2();(PIR1bits.TMR1IF==0){if (scroll==0) clock_set();};
} while (select==1);
}
clock_set(void)
{(scroll==0){};(select==1) {(scroll==1) {_draw();_2();_pos=12;_char_2();(select==0) {minutes++;}(minutes-60==0){++;=0;
} //if(hours-13==0){hours=0;}
} //while(scroll==0){};(scroll==1) {_draw();_2();_pos=13;_char_2();(select==0) {hours++;}(hours-13==0){hours=0;}
}(scroll==0){};(scroll==1) {_draw();_2();_pos=14;_char_2();(select==0)
{goto clock_set_end;}
}
}_set_end: while (select==0){};
}
clock_draw(void)
{temp_char;i,n;=seconds;=10;(temph,tempv_char);(temph<10) {tempc_char[n]=zero[0];_char[n+1]=tempv_char[0];}{tempc_char[n]=tempv_char[0];tempc_char[n+1]=tempv_char[1];}=minutes;=7;(temph,tempv_char);(temph<10) {tempc_char[n]=zero[0];_char[n+1]=tempv_char[0];}{tempc_char[n]=tempv_char[0];tempc_char[n+1]=tempv_char[1];}=hours;=4;(temph,tempv_char);(temph<10) {tempc_char[n]=zero[0];_char[n+1]=tempv_char[0];}{tempc_char[n]=tempv_char[0];tempc_char[n+1]=tempv_char[1];}_1();(i=0;i<ptr_count;i++)
{_char=tempc_char[i];_wr=temp_char;_write();
} //for i
}
stan_char_1(void)
{i;temp_char;_1();(i=0;i<ptr_count;i++)
{_char=stan_table[ptr_pos][i];_wr=temp_char;_write();
}
}stan_char_2(void)
{i;temp_char;_2();(i=0;i<ptr_count;i++)
{_char=stan_table[ptr_pos][i];_wr=temp_char;_write();
}
p18lcd.asm
********************************************************************
;* Microchip Technology Inc. 2002 *
;* Revised on 5/6/03 - Removed Linker file declaration *
;* Assembler version: 2.0000 *
;* Filename: *
;* p18lcd.asm *
;********************************************************************p=18f442
#include p18f442.inc
#define LCD_D4 PORTD, 0; LCD data bits
#define LCD_D5 PORTD, 1
#define LCD_D6 PORTD, 2
#define LCD_D7 PORTD, 3
#define LCD_D4_DIR TRISD, 0 ; LCD data bits
#define LCD_D5_DIR TRISD, 1
#define LCD_D6_DIR TRISD, 2
#define LCD_D7_DIR TRISD, 3
#define LCD_E PORTA, 1; LCD E clock
#define LCD_RW PORTA, 2; LCD read/write line
#define LCD_RS PORTA, 3; LCD register select line
#define LCD_E_DIR TRISA, 1
#define LCD_RW_DIR TRISA, 2
#define LCD_RS_DIR TRISA, 3
#define LCD_INS 0
#define LCD_DATA 1_LCD_DATA UDATAres 1res 1_wr res 1_rd res 1
GLOBAL temp_wrCODE_10x80temp_wri_writeLCDLine_1_20xC0temp_wri_writeLCDLine_2
;write data_write;temp_wr,TXREG;TXSTA,TRMT;$-2LCDBusySTATUS, CLCDWrited_write;instruction_writeLCDBusySTATUS, CLCDWrite i_write
rlcd macro MYREGISTERMYREGISTER == 1STATUS, CLCDReadSTATUS, CLCDReadPORTALCD_E_DIR;configure control linesLCD_RW_DIRLCD_RS_DIRb00001110ADCON10xff; Wait ~15ms @ 20 MHzCOUNTER0xFFdelayDelayXCyclesCOUNTER,Flil1b00110000; #1 Send control sequencetemp_wrSTATUS,CLCDWriteNibble
0xff; Wait ~4ms @ 20 MHz COUNTER
lil20xFFdelayDelayXCyclesCOUNTER,Flil2b00110000; #2 Send control sequencetemp_wrSTATUS,CLCDWriteNibble0xFF; Wait ~100us @ 20 MHzdelayDelayXCyclesb0011000; #3 Send control sequencetemp_wrSTATUS,CLCDWriteNibble
;test delay0xFF; Wait ~100us @ 20 MHzdelayDelayXCyclesb00100000; #4 set 4-bittemp_wrSTATUS,CLCDWriteNibbleLCDBusy; Busy?b00101000; #5 Function settemp_wri_writeb00001101; #6 Display = ON temp_wr
rcall i_writeb00000001; #7 Display Cleartemp_wri_writeb00000110; #8 Entry Modetemp_wri_writeb10000000; DDRAM addresss 0000temp_wri_write;b00000010;home;temp_wr;i_writeLCDInit;
_ ______________________________;_>--<______________________________;
_____;\_____________________________;
__________________;____________/ \___;
_____________ ______;_____________>--------------<______;STATUS, C; Set the register selectLCD_RSSTATUS, CLCD_RSLCD_RW; Set write modeLCD_D4_DIR; Set data bits to outputsLCD_D5_DIRLCD_D6_DIRLCD_D7_DIR; Small delayLCD_E; Setup to clock datatemp_wr, 7; Set high nibbleLCD_D7temp_wr, 7LCD_D7temp_wr, 6LCD_D6temp_wr, 6LCD_D6temp_wr, 5LCD_D5temp_wr, 5LCD_D5temp_wr, 4LCD_D4temp_wr, 4LCD_D4LCD_E; Send the data;LCDBusyLCDWriteNibbletemp_wr,FLCDWriteNibble
ПРИЛОЖЕНИЕ В. Подключаемый файл с описанием функций (продолжение)
swapf temp_wr,FLCDWrite;
_____ _____________________________________________________;_____>--<_________________________________________________;
___________