This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

problem with printf

I have a problem with the following code:

#pragma LARGE
#include <C8051F120.H>
#include <stdio.h>
char add(char a) reentrant
{
	printf("Data is %d\n",a);
	if(a==255)
	{
		return 0;
	}
	else
	{
		return add(a+1);
	}
}

void main()
{
    unsigned int uiData=0;
    SCON0  = 0x50;
    TMOD |= 0x20;
    TH1   = 0x96;
    TR1   = 1;
    TI0    = 1;
    add(0);
    while(1);
}

I am checking it with microvision 2 serial window.

the output I expect is
Data is 0
Data is 1
Data is 2
....

But what I am getting is

Data is 0
Data is 256
Data is 512
Data is 768
....

Can anyone tell me which is wrong? My expectation or my code?

- Neo

0