cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Explorer
Explorer
6,222 Views
Registered: ‎11-06-2011

Getting input from the user

Jump to solution

Hey guys.

 

I'm writing an application in SDK and I want to get an input from the user.

 

I tried to use the scanf command

 

scanf("%d", &Selection);

 

but it gave me the following error

 

Building target: memory_tests_1.elf
Invoking: PowerPC gcc linker
powerpc-eabi-gcc -Wl,-T -Wl,../src/lscript.ld -L../../memory_tests_bsp/ppc440_0/lib -mcpu=440 -o"memory_tests_1.elf"  ./src/IIC.o ./src/Main_Memory_Test.o ./src/My_Memory_Test.o ./src/memory_config_g.o ./src/platform.o   
/cygdrive/c/Xilinx/12.2/ISE_DS/EDK/gnu/powerpc-eabi/nt/bin/../lib/gcc/powerpc-eabi/4.1.1/../../../../powerpc-eabi/bin/ld: region xps_bram_if_cntlr_1 is full (memory_tests_1.elf section .text)
/cygdrive/c/Xilinx/12.2/ISE_DS/EDK/gnu/powerpc-eabi/nt/bin/../lib/gcc/powerpc-eabi/4.1.1/../../../../powerpc-eabi/bin/ld: region xps_bram_if_cntlr_1 is full (memory_tests_1.elf section .text)
/cygdrive/c/Xilinx/12.2/ISE_DS/EDK/gnu/powerpc-eabi/nt/bin/../lib/gcc/powerpc-eabi/4.1.1/../../../../powerpc-eabi/bin/ld: memory_tests_1.elf: section .text lma 0xffff8000 overlaps previous sections
collect2: ld returned 1 exit status
make: *** [memory_tests_1.elf] Error 1

 

I think this command is too heavy for the BRAM...

 

Is there another command I could use?

 

Thanks a lot.

 

Assaf.

0 Kudos
1 Solution

Accepted Solutions
Explorer
Explorer
7,559 Views
Registered: ‎11-06-2011

Re: Getting input from the user

Jump to solution

Sorry, I forgot to update.

 

At the end I used

 

Selection = XUartLite_RecvByte(XPAR_RS232_UART_1_BASEADDR);

 

and it worked.

 

Thanks a lot.

 

Assaf.

View solution in original post

0 Kudos
5 Replies
Highlighted
Teacher
Teacher
6,218 Views
Registered: ‎08-14-2007

Re: Getting input from the user

Jump to solution

Hi,

scanf, printf etc. cause the compiler to include the whole formating runtime code, which is huge.

You may use simpler commands like getc, putc but then you need to write extra code.

The C gurus probably can tell you more.

 

BRAM is a very limited ressource, even on large FPGAs.

So a system that requires programs to be fully stored in BRAMs (e.g. Bootloaders) has to be programmed very memory efficient. That means you can not use just any function that seems handy, but have always to look at the memory demand for these functions. Also coding style and compiler options have to comply with the requirement.

 

Have a nice synthesis

  Eilert

0 Kudos
Highlighted
Explorer
Explorer
6,216 Views
Registered: ‎11-06-2011

Re: Getting input from the user

Jump to solution

Thanks a lot.

 

Assaf.

0 Kudos
Highlighted
Explorer
Explorer
6,192 Views
Registered: ‎11-06-2011

Re: Getting input from the user

Jump to solution

Hey.

 

So I wrote getchar() and then I realized, where am I supposed to enter this input? :)

 

I'm using Tera Term, watching a COM port, where is the input suppose to go?

 

Thanks a lot.

 

Assaf.

0 Kudos
Highlighted
Teacher
Teacher
6,187 Views
Registered: ‎08-14-2007

Re: Getting input from the user

Jump to solution

Hi Assaf,

the UART has to be your stdin for using ch=getchar().

See the reference for details:

http://www.cplusplus.com/reference/clibrary/cstdio/getchar/

 

How your program deals with the return value needs to be described by you, the programmer.

Maybe you need to write some tiny parse and convert function.

I told you, that you need to spend some extra programming effort, but the result will be much smaller than the huge format runtimes for printf/scanf.

 

If you can not see the chars you typed on the screen in teraterm, then you need to set the terminal properties to autoreturn, so the chars appear on the screen, even whithout sending them back from your program.

 

Have a nice synthesis

  Eilert

 

0 Kudos
Explorer
Explorer
7,560 Views
Registered: ‎11-06-2011

Re: Getting input from the user

Jump to solution

Sorry, I forgot to update.

 

At the end I used

 

Selection = XUartLite_RecvByte(XPAR_RS232_UART_1_BASEADDR);

 

and it worked.

 

Thanks a lot.

 

Assaf.

View solution in original post

0 Kudos