- 90
- 0
- 约4.36千字
- 约 7页
- 2016-06-11 发布于重庆
- 举报
iccavr编译putchar未定义时解决方案
我在用iccavr编译程序“hello.c的时候,出现!ERROR file hello.o: undefined symbol _putcharE:\INSTAL~1\ICCAVR~1\bin\imakew.exe: Error code 1Done: there are error(s). Exit code: 1. Mon Nov 11 23:07:35 2013。
附上源程序如下:
#include iom128v.h#include macros.hunsigned char const SEGtable[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80};unsigned char rxtemp=0x00; void port_init(void) //端口初始化 { PORTA = 0xFF;
DDRA = 0xFF; PORTB = 0x00; DDRB = 0x00; PORTC = 0xFF; DDRC = 0xFF; PORTD = 0xFF; DDRD = 0x00; PORTE = 0x00; DDRE = 0x00; PORTF = 0xFF; DDRF = 0x00; PORTG = 0x00; DDRG = 0x00;}void uart0_init(void) //UART0初始化,8数据位,1位起始位,1位停止位,比特率为9600bps{ UCSR0B = 0x00; UCSR0A = 0x00; UCSR0C = 0x06; UBRR0L = 0x33; UBRR0H = 0x00; UCSR0B = 0xD8;}#pragma interrupt_handler uart0_rx_isr:19 //UART0接收数据中断服务子程序void uart0_rx_isr(void){ rxtemp = UDR0; putchar(rxtemp);}#pragma interrupt_handler uart0_tx_isr:21 //UART0发送数据中断服务子程序void uart0_tx_isr(void){}void init_devices(void)//系统初始化函数{ CLI(); XDIV = 0x00; XMCRA = 0x00; port_init(); uart0_init(); MCUCR = 0x00; EICRA = 0x00; EICRB = 0x00; EIMSK = 0x00; TIMSK = 0x00; ETIMSK = 0x00; SEI(); }unsigned char Fun(unsigned char X){ unsigned Y,Sum; static unsigned Z = 1; Y = 0;
Y = Y + 1; Z = Z + 1; Sum = Y + Z + X; return(Sum);
} void main(void){ unsigned char temp,i; init_devices(); for(i=0;i=5;i++) { temp = Fun(2); putchar(temp); }}
在网上找教程,说是在程序前面加上#include”stdio.h”,但是还是错误。后面通过一天都研究,发现了一个解决办法。
打开icc avr 安装目录,找到“example.avr”文件,打开其中”putchar_m16.c”文件,文件如下:
/* This putchar works with the M16 UART0. It will work with other devices * if their UART registers use the same names. If the UART IO locations * are different from the M16, then you will also have to change the * #include header file statement. * * For device with multiple UARTs and i
您可能关注的文档
- FIP香港金融实习项目(名企实习计划).docx
- Fifaszi制造业企业定岗定编和岗位定员管理办法.doc
- FK26+500~FK29+000土方路基施工技术方案.doc
- flexsim设计报告.doc
- fname=小学生基础知识.doc
- Forever电脑饰界策划书.doc
- FPGA设计交通灯技术规范和总体设计方案.doc
- freetalking策划书.doc
- FreeScaleHCS12X内核单片机实验指导书.doc
- FX2-485协议.doc
- 2025年全国演出经纪人员资格认定考试试卷带答案(研优卷).docx
- 2025年全国演出经纪人员资格认定考试试卷完整版.docx
- 2025年全国演出经纪人员资格认定考试试题库及完整答案.docx
- 2025年全国演出经纪人员资格认定考试试卷完美版.docx
- 2025年全国演出经纪人员资格认定考试试卷含答案(实用).docx
- 2025年全国演出经纪人员资格认定考试试卷及答案(各地真题).docx
- 2025年下半年内江市部分事业单位公开考试招聘工作人员(240人)备考题库附答案.docx
- 2025年全国演出经纪人员资格认定考试试卷及答案1套.docx
- 2025年下半年四川成都市郫都区面向社会引进公共类事业单位人员2人备考题库最新.docx
- 2025年下半年内江市部分事业单位公开考试招聘工作人员(240人)备考题库附答案.docx
原创力文档

文档评论(0)