Compare commits

..

No commits in common. "ebf06e4b0c79c2b3e196c98c684d601d744e077e" and "3334d7896c2750905feee385b9126d249205a1d2" have entirely different histories.

12 changed files with 2208 additions and 2412 deletions

2
.gitignore vendored
View File

@ -1,3 +1,3 @@
.vscode/ .vscode/
obj/* obj/*
*.hex uart_temp.hex

View File

@ -15,15 +15,12 @@ else
CC := ablrun sdcc CC := ablrun sdcc
COM := /dev/ttyUSB0 COM := /dev/ttyUSB0
endif endif
TEMP := $(shell sudo chmod 777 $(COM))
endif endif
# set uart baudrate
BAUD := 9600
# set CC TOOL # set CC TOOL
PACKIHX := packihx PACKIHX := packihx
CFLAGS := -DUSE_FLOATS=1 CFLAGS := -DUSE_FLOATS=1
LDFLAGS := --iram-size 0x100 --xram-size 0x400 --code-size 0xffff
# set DIR # set DIR
INCDIR = include INCDIR = include
@ -38,27 +35,23 @@ OBJ := $(patsubst src/%.c, obj/%.rel, $(SRC))
.PHONY: all clean .PHONY: all clean
all: main.hex all: uart_temp.hex
clean: clean:
-$(RM) obj/* -$(RM) obj\*
$(OBJ):obj/%.rel:src/%.c $(OBJ):obj/%.rel:src/%.c
-$(CC) $(CFLAGS) -I $(INC) -c $^ -o $@ -$(CC) $(CFLAGS) -I $(INC) -c $^ -o $@
$(TARGET): $(OBJ) $(TARGET): $(OBJ)
-$(CC) $(LDFLAGS) $^ -o $@ -$(CC) $^ -o $@
main.hex: $(TARGET) uart_temp.hex: $(TARGET)
-$(PACKIHX) $(TARGET) > main.hex -$(PACKIHX) $(TARGET) > uart_temp.hex
flash: flash:
-sudo chmod 777 $(COM) -stcgal -P stc89 -p $(COM) uart_temp.hex
-./reset_mcu.sh $(COM) $(BAUD)
-stcgal -P stc89 -p $(COM) main.hex
com:
-minicom -D $(COM) -b $(BAUD)
#led.bin:led.hex #led.bin:led.hex
# objcopy -I ihex -O binary led.hex led.bin # objcopy -I ihex -O binary led.hex led.bin

View File

@ -9,7 +9,6 @@ uart_temp是用于8051单片机上的一个项目用于获取温度并使
- 仅当温度变化时才会打印 - 仅当温度变化时才会打印
- 支持[SDCC](https://sdcc.sourceforge.net/)编译 - 支持[SDCC](https://sdcc.sourceforge.net/)编译
- 支持[stcgal](https://github.com/grigorig/stcgal)命令行烧录 - 支持[stcgal](https://github.com/grigorig/stcgal)命令行烧录
- 支持不断电烧录,发送"RESET!"命令后,软复位单片机,并自动重启。(`stcgal -a -r "./reset_mcu.sh"`的方式无法自动重启,原因未知)
- 支持Makefile - 支持Makefile
- 支持Window环境 - 支持Window环境
@ -39,14 +38,6 @@ uart_temp是用于8051单片机上的一个项目用于获取温度并使
4. 打开串口软件,接收来自单片机的数据 4. 打开串口软件,接收来自单片机的数据
串口波特率9600
```bash
minicom -D /dev/ttyUSB0 -b 9600
```
> 推荐使用图形化的串口软件:[COMtool](https://github.com/Neutree/COMTool/tree/master)
5. 运行`process.py`解析数据生成图片 5. 运行`process.py`解析数据生成图片
```bash ```bash
@ -57,7 +48,6 @@ uart_temp是用于8051单片机上的一个项目用于获取温度并使
# 运行脚本 # 运行脚本
python process.py python process.py
``` ```
![数据图片](./img.png) ![数据图片](./img.png)
## 更多的信息 ## 更多的信息

Binary file not shown.

BIN
img.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -7,15 +7,8 @@
typedef unsigned int u16; typedef unsigned int u16;
typedef unsigned char u8; typedef unsigned char u8;
// 用于自动重启的变量
__sfr __at (0xE7) ISP_CONTR;
#define RESET_PASSWORD_LENGTH 6
extern char __xdata reset_password[RESET_PASSWORD_LENGTH];
extern char __xdata receice_password[RESET_PASSWORD_LENGTH];
void delay_10us(u16 ten_us); void delay_10us(u16 ten_us);
void delay_ms(u16 ms); void delay_ms(u16 ms);
u8 auto_reset(u8 rec_data);
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@ from pylab import mpl
mpl.rcParams["font.sans-serif"] = ["SimHei"] mpl.rcParams["font.sans-serif"] = ["SimHei"]
# 初始化一个起始日期这里假设是今天凌晨0点 # 初始化一个起始日期这里假设是今天凌晨0点
start_date = datetime.now().replace(hour=20, minute=21, second=0, microsecond=0) start_date = datetime.now().replace(hour=0, minute=0, second=0, microsecond=0)
with open('minicom.cap', 'r') as file: with open('minicom.cap', 'r') as file:
lines = file.readlines() lines = file.readlines()
@ -21,11 +21,6 @@ for line in lines:
timedelta(minutes=int(time_str.split(':')[1])) + \ timedelta(minutes=int(time_str.split(':')[1])) + \
timedelta(hours=int(time_str.split(':')[0])) timedelta(hours=int(time_str.split(':')[0]))
temperature = float(temp_str) temperature = float(temp_str)
if len(temperatures) > 0:
pre_temp = temperatures[-1]
else:
pre_temp = temperature
if pre_temp-0.5 < temperature < pre_temp+0.5:
times.append(time) times.append(time)
temperatures.append(temperature) temperatures.append(temperature)

View File

@ -1,33 +0,0 @@
#!/bin/bash
#===========================================================================
# Organization : Individual developer
# Filename : reset_mcu.sh
# Author : Feng Bohan
# Create Time : 02:51:28 2024-07-14
# Last Modified: 00:17:44 2024-07-15
# Abstract :
#--------------------------------------------------------------------------
# Description:
#
#--------------------------------------------------------------------------
# Modification History:
#--------------------------------------------------------------------------
# Rev Date Who Description
# --- ---- --- -----------
# 0.0.01 2024-07-14 Feng Bohan initial version
#===========================================================================
if [ "$#" -ne 2 ]; then
echo "错误此脚本需要且仅需要2个参数, 作为COM口号和波特率。"
exit 1 # 使用非零状态码退出表示异常
fi
stty -F $1 speed $2 cs8 -parenb -cstopb raw -echo -echoe -echok -echoctl -echoke
echo -e "RESET!" > $1
#说明:
#speed 串口波特率
#cs8 数据位8位
#parenb 无校验
#cstopb 停止位1位
#查看串口设置: stty -a -F /dev/ttyUSB0

View File

@ -17,7 +17,6 @@
int HH=0, MM=0, SS=0; int HH=0, MM=0, SS=0;
int send_tmp = 0; int send_tmp = 0;
/******************************************************************************* /*******************************************************************************
* : main * : main
* : * :
@ -58,11 +57,7 @@ void main(void)
if(send_tmp == 1) { if(send_tmp == 1) {
send_tmp = 0; send_tmp = 0;
printf("%02d:%02d:%02d temp = %.1f\r\n", HH, MM, SS, temp_value/10.0); printf("%02d:%02d:%02d temp = %.1f\r\n", HH, MM, SS, temp_value/10.0);
// for(u8 i=0;i<RESET_PASSWORD_LENGTH;i++) {
// printf("i=%0d, %C[%x] = %C[%x] is %0d\r\n", i, reset_password[i], reset_password[i], receice_password[i], receice_password[i],receice_password[i]!= reset_password[i]);
// }
} }
} }
} }
@ -77,7 +72,6 @@ void uart(void) __interrupt (4) //串口通信中断函数
SBUF=rec_data; //将接收到的数据放入到发送寄存器 SBUF=rec_data; //将接收到的数据放入到发送寄存器
while(!TI); //等待发送数据完成 while(!TI); //等待发送数据完成
TI=0; //清除发送完成标志? TI=0; //清除发送完成标志?
auto_reset(rec_data);
} }
if(TI) if(TI)
{ {

View File

@ -23,31 +23,3 @@ void delay_ms(u16 ms)
for(i=ms;i>0;i--) for(i=ms;i>0;i--)
for(j=110;j>0;j--); for(j=110;j>0;j--);
} }
/*******************************************************************************
* : auto_reset
* : RESET!MCU
* :
* : 0:1:
*******************************************************************************/
char __xdata reset_password[RESET_PASSWORD_LENGTH] = "RESET";
char __xdata receice_password[RESET_PASSWORD_LENGTH] = {0};
u8 auto_reset(u8 rec_data)
{
for(u8 i=0;i<RESET_PASSWORD_LENGTH-1;i++)
{
receice_password[i] = receice_password[i+1];
}
receice_password[RESET_PASSWORD_LENGTH-1] = rec_data;
for(u8 i=0;i<RESET_PASSWORD_LENGTH-1;i++)
{
if(receice_password[i]!= reset_password[i])
{
return 1;
}
}
ISP_CONTR = 0x60; //软件复位并切换到系统ISP监控程序区开始执行程序
return 0;
}

View File

@ -1,3 +0,0 @@
import matplotlib
print(matplotlib.matplotlib_fname())
print(matplotlib.get_cachedir())