Forum Discussion

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

qsys_jtag_uart doubt

hi,

is it possible to print a series of number in nios 2 console using jtag uart along with nios2+onchip ram.

i am implemented an counter and made it as a custom component in qsys and i am using it

(adder+onchipram+nios 2+jtag uart).

i tried it but it is printing 0.

my c code:::::

--- Quote Start ---

/*

* main.c

*

* created on: jun 6, 2017

* author: dipin

*/

#include "stdio.h"

#include "io.h"

#include "system.h"

int main()

{

signed int ans;

ans = iord(counter_interface_0_base,0);

printf("%d",ans);

while(1);

return 0;

}

--- Quote End ---

" COUNTER_INTERFACE_0_BASE" is the same in my system.h file

my verilog code

--- Quote Start ---

module counter_jtag_check (clk,reset);

input clk;

input reset;

jtag_count u0 (

.clk_clk (clk), // clk.clk

.reset_reset_n (1'b1) // reset.reset_n

);

endmodule

--- Quote End ---

update:: i am able to print only one number.. ( i am counting from 1 to 65556, but its only printing 52429) so is it possible to print all numbers ?

can anybody please give any solutions???

--- Quote Start ---

while(1) {

ans = IORD(COUNTER_INTERFACE_0_BASE,0); printf("%d",ans); }

--- Quote End ---

i tride above c code also, but it is printing the same value again & again. my clock is 50mhz.

any help is really appriciated .

thanks and regards

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    If you only have onchip memory then you probably don't want to (can't) use printf - it creates/occupies too much code space. I'm surprised it compiles...

    You probably need to use "alt_printf". This creates minimal code, ideal for Nios implementations using onchip memory only. Refer to the "nios ii classic software developer’s handbook (https://www.altera.com/en_us/pdfs/literature/hb/nios2/n2sw_nii5v2.pdf)".

    Cheers,

    Alex
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    hi,

    i need to print a series of numbers. but alt_printf wont support numbers. so i am using printf.

    Anyway i solved my problem. now its printing fine and thanks much for replaying me :)

    regards