Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

printf() problem after IOWR and IORD

Hi

I faced to a problem with prinf() function..

in my C code when I wrote printf() after IOWR nothing was displayed out. but all the printf()s before IOWR were displayed in the jtag window.

I enabled the Reduced_driver option in the BSP editor this problem was solved and I don't know how?!

again with this new setting the printf() functions after IORD aren't displayed and I think the processor hanging on a deadlock!

I don't have any development board and see all the results in modelsim,I mean ,can't debug my C code to see what is happening during the execution of functions.

here is my C code:

 # include <stdio.h># include "system.h"# include <io.h># include "sys/alt_stdio.h"
 
int main(void)
{
 unsigned int read=0;
   printf("Hello from Nios II!\n");
  IOWR(TEST_LOGIC_BASE,0,0xFFFF);
  printf("after IOWR by reduced_driver option\n");
  read=IORD(TEST_LOGIC_BASE, 0);
  printf("after IORD\n");
  printf("value read from module: %h \n",read);
 
  return 0;
}

As you see I've put printf() functions all around IOWR and IORD!!at the result just these statements are shown in jtag window:

Hello form nios II!
after IOWR by reduced_driver option

I think IORD(TEST_LOGIC_BASE, 0) is executed too,because in the waves on modelsim, the read signal is asserted and the exact Data is put on read_data bus but it seems the processor(NIOS II)

doesn't come back to main() to fetch the rest of the codes..!

please help me if you have any experience about this problem

and if you know howcan I debug my code without any develpment board and just by simulating,please aware me.

thank you

12 Replies