Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6873809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:06:58+00:00 2026-05-27T04:06:58+00:00

I am helping a friend get a graphics LCD working on his AVR, a

  • 0

I am helping a friend get a graphics LCD working on his AVR, a few months ago all was working without issue, it has been untouched since then. The chip has now been swapped out from an ATMega32 to an ATMega164P. Essentially the same chip with more flash, since this change a lot of the code has stopped working.

We have narrowed where the error is occuring, but are unable to rectify it. It is where we pass in a pointer to a const char string, and attempt to print that string, however for some reason the stack(heap, something else?) gets corrupted and the pointer contains all zeros. Does anyone have any ideas how this could occur? We have -O1 level optimisations enabled which are required for correct timing, we have switched to winAVR compiler as well with no changes. We also do not have access to a debugger, and only have limited ‘print’ style debugging.

Here is the section of code that is causing issues:

//in the header file that is included
int SGCTEXTStringF(int column, int row, int font, int colour, const char* text);

//Call the function
SGCTEXTStringF(0, 0, 0x10, SGCColour(255,255,255), "text");

//Function
int SGCTEXTStringF(int column, int row, int font, int colour, const char* text){

unsigned char bytes[23]={0};

//...Code to communicate with LCD and set up a 'print string'

if(text[0] == 0) {
    bytes[6] = 'a'; 
    bytes[7] = 't';
    bytes[8] = 'e';
    bytes[9] = 's';
    bytes[10] = 't';
}

//..more code to finish sending the array
}

Now the display prints ‘atest’ when the code is run, this is showing that the const char array is being some how zero’d? I have also tried the following lines which also all print ‘atest’

if(text[1] == 0)   //prints 'atest'
if(*text== 0)      //prints 'atest'
if(text != 0)      //prints 'atest'

This shows that it gets a valid pointer, but it appears to point to all zeros.

We also tried changing the call to the method to:

const char * string = "test";
SGCTEXTStringF(0, 0, 0x10, SGCColour(255,255,255), string);

This code was known to be working a few months ago, we even have a video of it running, now every single function in the program exhibits the same issue, char arrays being passed (on the stack?) don’t seem to work and get cleared to 0s.

I can arrange to host a copy of the complete source code if anyone is interested. Any help or pointers at all are appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:06:59+00:00Added an answer on May 27, 2026 at 4:06 am

    The ATMega164P is not the replacement for the ATMega32 but for the ATMega16. For the ATMega32 you would need the ATMega324P.
    If you are using the memory map for the ATMega32 (which has double EEPROM, SRAM and flash), your string may have landed in memory which simply does not exist.
    For porting issues you may look at the porting guide from Atmel.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

helping my friend with his old ASP site and ran into an issue so
Helping a friend with his new tumblr blog. Anyway I preface this with that
Was helping a friend who has some 100+ Crystal Reports 2008 reports as part
I am helping a friend with his C# homework, but is being a long
I am helping a friend from first year to prepare his exam on Java.
thanks for helping me setting my cron jobs, crontab has really been a gold
I'm helping a colleague with a recurring issue that's just started happening to multiple
Thank you all for helping. Below this post I put the corrected version's of
I was helping a friend to write some Java code, who doesn't know a
I'm helping a friend with a java problem. However, we've hit a snag. We're

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.