led/src/main.c
2024-07-15 03:07:57 +08:00

73 lines
1.9 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**************************************************************************************
深圳市普中科技有限公司PRECHIN 普中)
技术支持www.prechin.net
实验名称DS18B20温度传感器实验
接线说明:
实验现象下载程序后插上DS18B20温度传感器数码管显示检测的温度值
注意事项:注意温度传感器的方向,在接口处我们已经用丝印画了一个凸起,
所以只需要将温度传感器对应插入即可
***************************************************************************************/
#include "public.h"
#include "uart.h"
#include "stdio.h"
#include "led.h"
/*******************************************************************************
* 函 数 名 : main
* 函数功能 : 主函数
* 输 入 : 无
* 输 出 : 无
*******************************************************************************/
void main(void)
{
uart_init(0XFA);//波特率为9600
u8 i = 0x01;
while(1)
{
// 实验一点亮LED
// led_all_on();
// delay_ms(1000);
// led_all_off();
// delay_ms(1000);
// 实验二:流水灯
// LED = ~i;
// i = rotate_left(i,1);
// delay_ms(1000);
// 实验三:蜂鸣器
BEEP=!BEEP;
delay_10us(100);
// printf("Hello,world!\r\n");
}
}
void uart(void) __interrupt (4) //串口通信中断函数
{
u8 rec_data;
if(RI)
{
RI = 0; //清除接收中断标志位
rec_data=SBUF; //存储接收到的数据
SBUF=rec_data; //将接收到的数据放入到发送寄存器
while(!TI); //等待发送数据完成
TI=0; //清除发送完成标志?
auto_reset(rec_data);
}
if(TI)
{
TI = 0;
busy = 0;
}
}
void time0(void) __interrupt (1) //定时器0中断函数
{
static u16 i;//定义静态变量i
TH0=0XFC; //给定时器赋初值定时1ms
TL0=0X18;
time0_delay_cnt++;//计数器自增
}