cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Visitor
Visitor
4,260 Views
Registered: ‎11-11-2009

problem taking input from hyperterminal-help!!!

i am using EDK 10.1 and Spartan 3E

i had written a very basic code to take two integers from the user and display the sum. the code looks something like this

 

 

 

#include "stdio.h"

 

int main(void)

{

 

         int a,b,c;

         xil_printf("enter the first no:");

         scanf("%d",&a);

         xil_printf("enter the second no:");

         scanf("%d",&b);

        c=a+b;

         xil_printf("result is %d",c);

        return(0)

}

 

 

the hyperterminal receives the first no. but does not accept the second no and the result displayed is a garbage no.

I dont  know what the problem is.pls help

 

 

 

 

0 Kudos
4 Replies
Highlighted
4,253 Views
Registered: ‎08-21-2008

Hello.

Try this code and also compare your code with this.

Note:Do check your base address for UART controller. 

*********************************************************

#include "xuartlite_l.h"
#include "xio.h"

main()
{
Xuint8 data1,data2,sum;

xil_printf("\n\rEntering MAIN\n\r");
while(1)
{
data1 = XUartLite_RecvByte (baseaddr);
data2 = XUartLite_RecvByte (baseaddr);

sum = data1+data2
xil_printf("\nSUM=0x%x", sum);
}
}
Best of luck.
--
Unlimited in my Limits.
0 Kudos
Highlighted
Visitor
Visitor
4,181 Views
Registered: ‎11-11-2009

Hey

Thanks alot tat code worked out for us .

I have one more doubt for - are pointers acceptable in sdk? We are workin on Hauffman codec for which we need to creat trees and so we need pointers. Can u pls throw some light on this problem.

Thank you. 

0 Kudos
Highlighted
4,178 Views
Registered: ‎08-21-2008

Hello.

As far as pointers are concerned its a feature of C language.

SDK supports C so i don't think there is any point for unacceptance of pointers in SDK.

Pointers are not tool dependent.

Although i haven't used SDK much but its logical.

Message Edited by prateek_bhatt on 11-21-2009 12:55 AM
Best of luck.
--
Unlimited in my Limits.
0 Kudos
Highlighted
Visitor
Visitor
4,167 Views
Registered: ‎07-31-2009

Pointer can be used for sure, I am using it. Please note that once you use malloc() function or c++ new operation, be sure that the heap size is set correctly in the linker script so that you can manage the memory.

 

 

0 Kudos