Forum : 8051
Original Post
Post Information | Post |
---|---|
May 7, 2007 - 10:35pm
|
RC51 gives errors when accessing arrays in this way unsigned xdata char c; z[c] = func(); A workaround is to split the offending code line with a dummy variable i.e: n = z[c] / 16; The RIDE build is 6.4.43. I've sent code files and other details directly to Raisonance. Steven Pruzina |
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.
Is this a known problem? The RIDE51 build is 6.4.37. Memory model is SMALL.
Apologies to Steven Pruzina - this was mis-posted here and there does not seem to be any way to edit or delete it. I will re-post it to the general forum.
Campbell Kelly.