#include<avr/io.h>
int main(void)
{
}
2.这里要注意的是二进制的使用方法
#include<avr/io.h>
int main(void)
{
}
3.第一个闪烁灯
#include<avr/io.h>
int main(void)
{
}
4.独立按键实验
//普通io口检测独立键盘的实验
#include<avr/io.h>
int main(void)
{
}
5.//普通io口检测独立键盘的实验(运用switch语句)
#include<avr/io.h>
void delay( );
int main(void)
{
}
void delay()
{
}
6.外部中断的应用
#include<avr/io.h>
#include<avr/interrupt.h>
void delay( );
int main(void)
{
}
SIGNAL(SIG_INTERRUPT0)
{
}
SIGNAL(SIG_INTERRUPT1)
{
}
void delay()
{
}
7. 利用查询方式进行定时中断
#include<avr/io.h>
#include<avr/interrupt.h>
int main(void)
{
}
8.定时中断
#include<avr/io.h>
#include<avr/interrupt.h>
void delay( );
int main(void)
{
}
volatile unsigned int cnt=0;
SIGNAL(SIG_OVERFLOW0)
{
}
9.系统中断定时器
#include<avr/io.h>
#include<avr/interrupt.h>//使用中断函数是要用到
int main()
{
//定时器初始化
}
volatile unsigned int cnt = 0; //在中断服务程序里的变量都需要加volatile
SIGNAL(SIG_OVERFLOW0)
{
}
10.USART 单片机发送程序
#include<avr/io.h>
#include<avr/interrupt.h>//使用中断函数时要用到
#define F_MCU 7372800
#define BAUD 9600
unsigned char aa[40]={"Congratulation ball ! you are success!"};
void Init_USART()
{
}
void Send_Data(unsigned char data)
{
}
int main()
{
unsigned char i=0;
Init_USART();
}
11.USART单片机接收上位机发送的数据并发回上位机
#include<avr/io.h>
#include<avr/interrupt.h>//使用中断函数时要用到
#define F_MCU 7372800
#define BAUD 9600
unsigned char aa[40]={"Congratulation ball ! you are success!"};
unsigned char i;
void Init_USART()
{
}
void Send_Data(unsigned char data)
{
}
volatile unsigned char recv_data=0;
SIGNAL(SIG_UART_RECV)
{
}
int main()
{
}