单片机解密MC96F6508A测温程序
单片机解密单片机源程序如下:
- /*****************************************************************
- * *
- * temperature *
- * *
- *单片机解密 MCU 芯片: 单片机解密MC96F6508A 工作频率: 16MHz *
- ******************************************************************/
- #include <mc96f6508a.h>
- #include <intrins.h>
- #include "MC96F6508A.h"
- #include "func_def.h"
- #include "lcd.h"
- #include "temp.h"
-
- #define uchar unsigned char
- #define uint unsigned int
- void LcdDisplay(int);
- /*******************************************************************************
- * 函数名 : main
- * 函数功能 : 主函数
- * 输入 : 无
- * 输出 : 无
- *******************************************************************************/
- main()
- {
- P1IO = 0xff; // 输出P1 Direction Register
- P1OD = 0xff; //漏极开路输出 P1 Open-drain Selection Register
- P1PU = 0xff; // 内部上拉电阻P1 Pull-up Resistor Selection Register
- P1DB = 0xff; //消抖
-
- P2IO = 0xf0; // 输出P1 Direction Register
- P2OD = 0x00; //漏极开路输出 P1 Open-drain Selection Register
- P2PU = 0xff; // 内部上拉电阻P1 Pull-up Resistor Selection Register
- P2FSR = 0x00; //
- P3IO = 0xff; // 输出P1 Direction Register
- P3OD = 0x00; //漏极开路输出 P1 Open-drain Selection Register
- P3PU = 0xff; // 内部上拉电阻P1 Pull-up Resistor Selection Register
- P3FSR = 0x00; //消抖
-
-
- P4IO = 0xff; // 输出P1 Direction Register
- P4OD = 0xff; //漏极开路输出 P1 Open-drain Selection Register
- P4PU = 0xff; // 内部上拉电阻P1 Pull-up Resistor Selection Register
- P4FSR = 0x00; //消抖
- P5IO = 0xff; // 输出P1 Direction Register
- P5OD = 0xff; //漏极开路输出 P1 Open-drain Selection Register
- P5PU = 0xf0; // 内部上拉电阻P1 Pull-up Resistor Selection Register
- P5FSRH = 0xff; //
- P5FSRL = 0xff;
- P6IO = 0xff; // 输出P1 Direction Register
- P6OD = 0xff; //漏极开路输出 P1 Open-drain Selection Register
- P6PU = 0xff; // 内部上拉电阻P1 Pull-up Resistor Selection Register
- P6FSR = 0x0f; // 设置为Xin/Xout
-
- P0IO = 0x00; // 输出P1 Direction Register
- P0OD = 0xff; //漏极开路输出 P1 Open-drain Selection Register
- P0PU = 0xff; // 内部上拉电阻P1 Pull-up Resistor Selection Register
- P0DB = 0xff; //消抖
-
- P4=0xff;
- // internal RC clock (16.000000MHz)
- OSCCR = 0x08; // Set Int. OSC
- SCCR = 0x00; // Use Int. OSC
- //P4=0x00;
- //DSPORT=0;
- //OSCCR = 0x28; // 外部主时钟
- //SCCR = 0x00; // 打开外部主时钟
- LcdInit(); //初始化LCD1602
- LcdWriteCom(0x88); //写地址 80表示初始地址
- LcdWriteData('C');
- while(1)
- {
- LcdDisplay(Ds18b20ReadTemp());
- //Delay1ms(1000);//1s钟刷一次
- }
- }
- /*******************************************************************************
- * 函数名 : LcdDisplay()
- * 函数功能 : LCD显示读取到的温度
- * 输入 : v
- * 输出 : 无
- *******************************************************************************/
- void LcdDisplay(int temp) //lcd显示
- {
-
- unsigned char datas[] = {0, 0, 0, 0, 0}; //定义数组
- float tp;
- if(temp< 0) //当温度值为负数
- {
- LcdWriteCom(0x80); //写地址 80表示初始地址
- LcdWriteData('-'); //显示负
- //因为读取的温度是实际温度的补码,所以减1,再取反求出原码
- temp=temp-1;
- temp=~temp;
- tp=temp;
- temp=tp*0.0625*100+0.5;
- //留两个小数点就*100,+0.5是四舍五入,因为C语言浮点数转换为整型的时候把小数点
- //后面的数自动去掉,不管是否大于0.5,而+0.5之后大于0.5的就是进1了,小于0.5的就
- //算由?.5,还是在小数点后面。
- }
- else
- {
- LcdWriteCom(0x80); //写地址 80表示初始地址
- LcdWriteData('+'); //显示正
- tp=temp;//因为数据处理有小数点所以将温度赋给一个浮点型变量
- //如果温度是正的那么,那么正数的原码就是补码它本身
- temp=tp*0.0625*100+0.5;
- //留两个小数点就*100,+0.5是四舍五入,因为C语言浮点数转换为整型的时候把小数点
- //后面的数自动去掉,不管是否大于0.5,而+0.5之后大于0.5的就是进1了,小于0.5的就
- //算加上0.5,还是在小数点后面。
- }
- datas[0] = temp / 10000;
- datas[1] = temp % 10000 / 1000;
- datas[2] = temp % 1000 / 100;
- datas[3] = temp % 100 / 10;
- datas[4] = temp % 10;
- LcdWriteCom(0x82); //写地址 80表示初始地址
- ……………………

芯片解密