Altera_Forum
Honored Contributor
11 years agoa question for printf() function
hi everyone:
i made a nios project, use jtag-uart, the code is as follows:# include "alt_types.h"# include "altera_avalon_pio_regs.h"# include "sys/alt_irq.h"# include "system.h"# include <stdio.h># include <unistd.h> void delay(void); int main(void) { alt_u8 timer = 0; while(1) { printf("Hello NIOS II! %d\n",timer); IOWR_ALTERA_AVALON_PIO_DATA(PIO_BASE,timer); // connect to a led delay(); timer++; } return 0; } //延时函 void delay(void) { alt_u32 i=0; while(i < 4000000) { i++; } } the function of the code is very simple: use jtag-uart output ""Hello NIOS II! timer" and make a led blink. the project works correct when i first download the *.sof file and then download *.elf file. i see the jtag-uart receive data and the led blinking. then i want to download the configure file to the EPCS Serial Configuration Device, so i add a EPCS Controller Core, and then download the configure file. then problem comes: i find the led only blink once. if i comment the printf() function, the led starts blinking. why? is it because the jtag-uart is not on receive mode so the code stuck in the printf() function? i think the jtag-uart printf() function is very useful during programming for debug, it can send out a lot information, such as whether a component works correct. does it mean that i should comment all the jtag-uart printf() when i want to download the configure file to the EPCS Device?? thanks