程序如下,就是串口发送,这么简单怎么下载后没有反应呢?
M128芯片。ICC编译器。
熔丝如下。
#include <iom128v.h>
#include <macros.h>
#define uchar unsigned char
#define uint unsigned int
#define f_count 183 //定时器初值,定时器加1计数
#define timer_clk 0x07 //时钟1024分频
#define fosc 8000000 //晶振8M
#define baud 2400 //波特率
uchar time_1s_count =0;
uint second;
uint A1,A2,A3;
uint dly;
void Port_init(void)
{
PORTC=0X7a; //亮3个灯
DDRC =0XFF;
}
/*---------------------------------------------------------------------------------
延时程序计算方法
计数个数j = 延时时间/6*晶振频率 - 1
---------------------------------------------------------------------------------*/
void uart_init(void)
{
UCSR0B =0X00;
UCSR0A =0X00;
UCSR0C =(1<<UCSZ01)|(1<<UCSZ00); //8个数据位
UBRR0L=(fosc/16/(baud+1))%256;
UBRR0H=(fosc/16/(baud+1))/256;
UCSR0B=(1<<RXEN0)|(1<<TXEN0); //使能接收发送
}
void putchar0(unsigned char c)
{
while(!(UCSR0A&(1<<UDRE0))); //发送器已经准备就绪
UDR0=c; //数据放进SBUF
}
unsigned char getchar0(void)
{
while(!(UCSR0A&(1<<RXC0))); //接收完毕
return UDR0;
}
//--------------------------------------------------------------------------------
void puts0(char *s)
{
while(*s !='\0')
{
putchar0(*s);
s++;
}
}
/*---------------------------------------------------------------------------------
---------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------------
---------------------------------------------------------------------------------*/
void main(void)
{
uchar i,j; //定义变量
Port_init();
uart_init();
i=1;
puts0("HELLO");
while(1)
{
dly++;
if(dly>60000)
{
dly=0;
puts0("test ok!");
}
}
}
|