#include <iom8v.h>
#include <macros.h>
#define uchar unsigned char
#define uint unsigned int
//**********延时函数***************
void delay(unsigned int k)
{
unsigned int i,j;
for(i=0;i<k;i++)
{
for(j=0;j<121;j++)
{;}
}
}
void uart0_init(void)
{
UCSRB = 0x00; //disable while setting baud rate
UCSRA = 0x00; //控制和状态寄存器
UCSRC = BIT(URSEL) | 0x06; //寄存器 数据帧字长选择8位
UBRRL = 0x2F; //set baud rate lo 波特率寄存器
UBRRH = 0x00; //set baud rate hi
UCSRB = 0x48; //开接受中断 接收使能 发送使能
}
void main(void)
{
DDRC |= BIT(2);
  ORTC |= BIT(2);
DDRD |= BIT(2);
  ORTD |= BIT(2);
uart0_init();
SREG |= BIT(7);
while(1)
{
while( !( UCSRA & (1<<UDRE)) );
UDR = 0X0F ;
delay(500);
}
}
#pragma interrupt_handler uart0_tx_isr:14
void uart0_tx_isr(void)
{
}
|