|
使用icc编译
串口调试助手发送1,但是助手收不到数据啊
查看eeprom里已经写入值了
请老师指点
#include <iom16v.h>
#include "macros.h" // 常用的宏定义
#include "eeprom.h"
#include "stdio.h"
#define uchar unsigned char
#define uint unsigned int
//eeprom区定义
#pragma data:eeprom
char table[]={0x01,0x02,0x03,0x04,0x05};
#pragma data: data
uchar *q=table;
int flag=UDR;
int i;
void uart0_init(void)
{
UCSRB = 0x00; //disable while setting baud rate
UCSRA = 0x00;
UCSRC = BIT(URSEL) | 0x06;
UBRRL = 0x33; //set baud rate lo
UBRRH = 0x00; //set baud rate hi
UCSRB = 0x98;
}
/***************************************
串口输出函数
****************************************/
void putc(unsigned char c)
{
while (!(UCSRA&(1<<UDRE)));
UDR=c;
}
#pragma interrupt_handler uart0_rx_isr:12
void uart0_rx_isr(void)
{
//uart has received a character in UDR
if(flag==1)
{
for(i=0;i<=4;i++)
{
putchar(EEPROMread((unsigned int)(q++)));
}
}
}
void main()
{
CLI();
uart0_init();
SEI();
while(1)
{
;
}
} |
阿莫论坛20周年了!感谢大家的支持与爱护!!
知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)
|