Hi Daniel,
Thanks for your support. I'm not an english mother tongue speaker, so I may not be so accurate when describing my issue. I do apologize for that.
The project has been created in small model.
The stack starts in 0x86F down to 0x76F (256 bytes) and is far from overflow.
Here is the full code.
GLCD_DisplayValue, makes conversion from a decimal value into ASCII in order to display on a graphic LCD.
Code:
/*-------------------------------------------------------------------------------Convert a digital value into an ASCII string GLCD_DisplayValue (U32 u32Value, U8 u8NumberOfIntegerDigits, U8 u8NumberOfDecimalDigits) u32Value = 32 bits Value to display u8NumberOfIntegerDigits = Number of interger digits. If this number is higher than the number of integer digits, it will display the non significant '0' u8NumberOfDecimalDigits = Number of decimal digits *stFont = font to use -------------------------------------------------------------------------------*/void GLCD_DisplayValue (U32 u32Value, U8 u8NumberOfIntegerDigits, U8 u8NumberOfDecimalDigits, FONT_DEF *stFont, U8 u8Type) { U8 *au8ValueToDisplay; au8ValueToDisplay = UTIL_LongToAscii(u32Value, u8NumberOfIntegerDigits, u8NumberOfDecimalDigits); /* Display the string */ GLCD_Printf(au8ValueToDisplay, stFont, u8Type);}
The array au8ValueToDisplay contains the ASCII chars to display. The function call the GLCD_Printf function with the pointer to the array as one of the parameters.
When arriving in GLCD_Printf, everything works well.
Code:
/*-------------------------------------------------------------------------------Print a string on the LCD GLCD_Printf (U8 *au8Text) *au8Text = string to display *stFont = font to use-------------------------------------------------------------------------------*/void GLCD_Printf (U8 *au8Text, FONT_DEF *stFont, U8 u8Type) { while(*au8Text != 0) { LcdPutchar (*au8Text, stFont, u8Type); au8Text++; }}
au8Text pointer is located in 0x84A and contains the value 0x838. The array (located in 0x838) contains the 3 ASCII bytes and everything is still correct there.
The function call LcdPutchar in a loop to display char after char as long as the NULL char has been detected. char is given as a parameter of LcdPutchar.
Code:
/*-------------------------------------------------------------------------------Print a char on the LCD GLCD_Putchar (U8 u8Char) u8Char = char to display-------------------------------------------------------------------------------*/void LcdPutchar (U8 u8Char, FONT_DEF *stFont, U8 u8Type){ U8 u8CharColumn=0,u8RightSide=0;
When reaching the function, the pointer in 0x84A and the array in 0x838...0x83A are still correct.
But when running the U8 u8CharColumn=0, this variable located in 0x83A overwrites the last char of my array .... When coming back for the second time in the function, the char in 0x839 is then overwritten, and so on....
This code has been compiled with Keil C compiler for 8051 and was working well. This is why I was assuming the code correct and a bug in the compiler HC08... But I may have badly used the C language.
Do you see in my method something wrong ?
Best
Stephane