资源描述:
《PIC单片机温度检测》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、;*************************************************;*heat.asm**;*************************************************;*本程序为热敏电阻输入处理模块程序;*将温度值在LCD特定位置显示;*占用I/ORA1;*使用RAM3个字节;*程序包括:;*-TempM热敏电阻输入处理子程序;*-CalTable温度值校准处理子程序;*-Bin2BCDT-二进制数转两位ASCII码子程序;*入口参数无;*出口参数TempH,TempL(温度值);**********
2、***************************************#includep16f876a.inc;定义所用单片机的头文件;****************************************************externInitLCD,putcLCD,SendCmd,clrLCD;定义外部函数;****************************************************heat_groupudata;数据区;******************************************
3、*********Tempres1TempHres1TempLres1globalTempHglobalTempL;************************************************PROG_HEATCODE;程序区;************************************************CalTable;温度校正函数bcfSTATUS,RP0movlw0x3A;进行校准处理(调整该处值以得到正确的温度值)subwfTemp,w;addwfPCL,f;将补偿结果与PCL相加;*注意:要通过反汇编查看Cal
4、Table函数是否跨页(这里的跨页指PCL溢出),若跨页则要调整该函数位置dt0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5dt6,6,6,7,7,7,8,8,8,9,9,0xa,0xa,0xb,0xb,0xc,0xcdt0xd,0xd,0xe,0xe,0xf,0xf,0xf,0x10,0x10,0x10dt0x11,0x11,0x12,0x12,0x12,0x13,0x13,0x14,0x14,0x14dt0x15,0x15,0x15,0x16,0x16,0x16,0x17,0x17,0x18,0x18dt0x1
5、9,0x19,0x1a,0x1a,0x1b,0x1b,0x1c,0x1c,0x1cdt0x1d,0x1d,0x1d,0x1e,0x1e,0x1f,0x1f,0x20,0x20dt0x21,0x21,0x22,0x22,0x23,0x23,0x24,0x24,0x25,0x25dt0x26,0x26,0x27,0x28,0x29,0x29,0x2a,0x2a,0x2b,0x2bdt0x2c,0x2d,0x2e,0x2f,0x30,0x32;********************************************************TempM
6、;热敏电阻输入处理globalTempMbsfSTATUS,RP0;初始化RA2movlw0x02movwfADCON1;ADRESHall8-bitbcfSTATUS,RP0movlwb'01001001';selectAD1,FOSC/8movwfADCON0;movlw0x10;延时movwfTempdecfszTemp,Fgoto$-1bsfADCON0,GO;启动转换btfscADCON0,GOgoto$-1movfADRESH,W;读取转换结果的高8位movwfTempmovlwHIGHCalTable;进行校正movwfPCLATHcallCa
7、lTablemovwfTempcallBin2BCDT;进行BCD码调整return;************************************************;*Bin2BCDT-将Temp寄存器内的二进制数转*;*换为相应的ASCII码并存为TempH:TempL的形式*;************************************************Bin2BCDTbcfSTATUS,RP0clrfTempH;InitializevariablesmovfTemp,WmovwfTempLTtenth;Subtrac
8、t10fromlowvariablemovlw.10