芯片解密STC89C51单片机+HX711称重模块
芯片解密单片机源程序如下:
- 芯片解密#include <reg52.h>
- 芯片解密#include <intrins.h>
- 芯片解密#include <string.h>
- 芯片解密#include "main.h"
- 芯片解密#include "HX711.h"
- 芯片解密#include "eeprom52.h"
- #define uchar unsigned char
- #define uint unsigned int
- unsigned long HX711_Buffer = 0;
- unsigned long Weight_Maopi = 0;
- unsigned long Weight_Maopi_0 = 0;
- long Weight_Shiwu = 0;
- unsigned int qupi=0;
- unsigned char p=0;
- //键盘处理变量
- unsigned char keycode;
- unsigned char key_press_num=0;
- uint GapValue,GapValue1;
- bit flag_cz=0;
- uchar code LEDData[]={0x5F,0x44,0x9D,0xD5,0xC6,0xD3,0xDB,0x47,0xDF,0xD7,0xCF,0xDA,0x9B,0xDC,0x9B,0x8B}; //数码管显示码表
- //定义标识
- volatile bit FlagTest = 0; //定时测试标志,每0.5秒置位,测完清0
- volatile bit FlagKeyPress = 0; //有键按下标志,处理完毕清0
- //校准参数
- //因为不同的传感器特性曲线不是很一致,因此,每一个传感器需要矫正这里这个参数才能使测量值很准确。
- //当发现测试出来的重量偏大时,增加该数值。
- //如果测试出来的重量偏小时,减小改数值。
- //该值可以为小数
- //#define GapValue 349
- sbit LED=P1^1;
- sbit ROW1=P3^0;
- sbit ROW2=P3^1;
- sbit ROW3=P3^2;
- sbit ROW4=P3^3;
- sbit DIAN = P0^5; //小数点
- volatile bit ClearWeighFlag = 0; //传感器调零标志位,清除0漂
- /******************把数据保存到单片机内部eeprom中******************/
- void write_eeprom()
- {
- SectorErase(0x2000);
- GapValue1=GapValue&0x00ff;
- byte_write(0x2000, GapValue1);
- GapValue1=(GapValue&0xff00)>>8;
- byte_write(0x2001, GapValue1);
- byte_write(0x2060, a_a);
- }
- /******************把数据从单片机内部eeprom中读出来*****************/
- void read_eeprom()
- {
- GapValue = byte_read(0x2001);
- GapValue = (GapValue<<8)|byte_read(0x2000);
- a_a = byte_read(0x2060);
- }
- /**************开机自检eeprom初始化*****************/
- void init_eeprom()
- {
- read_eeprom(); //先读
- if(a_a != 1) //新的单片机初始单片机内问eeprom
- {
- GapValue = 3500;
- a_a = 1;
- write_eeprom(); //保存数据
- }
- }
- /*****显示开机初始化等待画面*****/
- void Disp_init(void)
- {
- P0 = ~0x80; //显示----
- P2 = 0xBF; //依次打开各位
- Delay_ms(1); //延时
- P2 = 0xEF;
- Delay_ms(1);
- P2 = 0xFB;
- Delay_ms(1);
- P2 = 0xFE;
- Delay_ms(1);
- P2 = 0xFF; //关闭显示
- }
- //显示重量,单位kg,两位整数,三位小数
- void Display_Weight()
- {
- P0 = ~LEDData[Weight_Shiwu%10]; //
- P2 = 0xBF; //打开位
- Delay_ms(1); //延时
- P2 = 0xff; //关闭显示
- P0=~LEDData[Weight_Shiwu%100/10]; //显示个位
- P2 = 0xEF;
- Delay_ms(1);
- P2 = 0xff; //关闭显示
- P0 =~LEDData[Weight_Shiwu%1000/100]; //显示十位
- P2 = 0xFB;
- Delay_ms(1);
- P2 = 0xff; //关闭显示
- P0 =~LEDData[Weight_Shiwu%10000/1000]; //显示百位
- DIAN = 0; //显示小数点
- P2 = 0xFE;
- Delay_ms(1);
- P2 = 0xff; //关闭显示
- }
- //定时器0初始化
- void Timer0_Init()
- {
- ET0 = 1; //允许定时器0中断
- TMOD = 1; //定时器工作方式选择
- TL0 = 0xb0;
- TH0 = 0x3c; //定时器赋予初值
- TR0 = 1; //启动定时器
- }

芯片解密