Topic : printf error with Atmel 89C5131A?

Forum : 8051

Original Post
Post Information Post
July 13, 2007 - 11:16am
Guest

There seems to be a problem with the printf() function on the Atmel 89C5131A device. The code fragment below sends correct data using putchar and incorrect data using printf.

code const char test[] = "USBC test V1.04";

void main(void)
{
int i;

PLLCON = 0x04; // disable the clock oscillator and PLL (48MHz direct clock)
CKCON0 = 0x01; // select X2 mode
set_serial(57600); // set up the UART

i = 0;
do {
putchar(test[i++]);
}
while (test[i] != 0);

putchar(0x0D);
putchar(0x0A);

printf("1234567890");

for (;;;)
;
}

The output is:

USBC test V1.04
1234567st V1.04

instead of

USBC test V1.04
1234567890

Using just the printf() function with a string pointer and without the preceding calls to putchar() produces even stranger results.

The R51 version is 6.4.37, and the memory model is SMALL.

Has anyone else seen this behaviour?