| 
 
| //main.c #include <avr/io.h>
 
 #include "includes.h"
 #include "global.h"
 #include <util/delay.h>
 #include <avr/interrupt.h>
 #include <avr/pgmspace.h>
 
 //#define F_CPU 16000000L
 
 int main(void)
 {
 GPIO_Configuration();
 //TIM_Configuration();
 //DDRB = 0XFF;
 
 while(1)
 {
 PORTB = 0X00;
 _delay_ms(1000);
 PORTB = 0XFF;
 _delay_ms(1000);
 }
 
 return 0;
 }
 
 //gpio.c
 #include <avr/io.h>
 
 /*******************************************************************************
 *  函数名称 :
 *
 *  功    能 :  I/O口初始化
 *
 *  输入参数 :
 *
 *  返 回 值 :
 *******************************************************************************/
 void GPIO_Configuration()
 {
 DDRB = 0XFF; /*配置PB口为输出模式,PB4为T/C0的输出比较和PWM输出,PB5为T/C1的输出比较和PWM输出A,PB6为T/C1的输出比较和PWM输出B,PB7为T/C2的输出比较和PWM输出,或是T/C1的输出比较和PWM输出C*/
 //DDRD = 0Xff; /*配置PD口为输出模式*/
 //DDRE = 0X0e; /*配置PE0,4,5,6,7口为输入模式,其余为输出模式,PE0为RXD0,PE1为TXD0串口和PE4,5,6,7按键初始化*/
 
 //PORTB = 0X00; /*让PB0输出低电平,其余为高*/
 //PORTD = 0X00; /*让PD0输出高电平,外部中断0的I/O初始化*/
 //PORTE = 0X0f; /*让PE口输出高*/
 }
 
 //global.h
 #ifndef _GLOBAL_H_
 #define _GLOBAL_H_
 
 /*******************************************************************************
 *
 *  函数申明
 *
 *******************************************************************************/
 void GPIO_Configuration();
 void TIM_Configuration();
 void tim2_delayms(unsigned int time);
 void LED_1S();
 void USART_Configuration(unsigned int baud);
 void USART0_Transmit_char(unsigned char USART_data);
 void USART0_Transmit_string(unsigned char* USART_string);
 unsigned char USART0_Receive();
 void Extern_Configuration();
 void Watchdog_Configuration();
 
 /*******************************************************************************
 *
 *  全局变量的申明
 *
 *******************************************************************************/
 extern unsigned int tim2_num;
 
 #endif
 | 
 |