Saras015
Banned
Hi all,
I am trying out an e.g. "Factorial" Program in SDK. I need to give input in Tera Terminal and answer should be printed back on the Console.
Suppose if i input "Enter the number " = 5 (In terminal), i need to get the result back = 120 on the console screen back. Please help me what syntax should use in the coding section to input and to get output on the screen.
I have used "XUartLite_RecvByte(XPAR_UARTLITE_0_BASEADDR)", but not working.
Thanks.
I am trying out an e.g. "Factorial" Program in SDK. I need to give input in Tera Terminal and answer should be printed back on the Console.
Suppose if i input "Enter the number " = 5 (In terminal), i need to get the result back = 120 on the console screen back. Please help me what syntax should use in the coding section to input and to get output on the screen.
I have used "XUartLite_RecvByte(XPAR_UARTLITE_0_BASEADDR)", but not working.
Code:
int main (void)
{
int input;
int i;
uint32_t fact=1;
while(1)
{
//reads from the Hyperterminal
input= XUartLite_RecvByte(XPAR_UARTLITE_0_BASEADDR);
if ((input>= 0x30) && (input <= 0x37))
{
//prints the data read from the HyperTerminal
{
fact =fact*input;
}
xil_printf("%d ", fact);
}
else
{
xil_printf("\n\r please enter a VALID number (0 -> 7)\n\r");
}
}
}
Thanks.
Last edited by a moderator: