This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430F5659: Strange issue during debug

Part Number: MSP430F5659


Good morning TI experts!

I'm here today because I have some problems (unpredictable, I think) while I'm testing the code I wrote in debug mode.

Let me explain the situation better: I'm writing a keyboard&notepad application and I use FT812 controller for my display.

At some point during the Keyboard() routine I've noticed that the processor stops working correctly.

So I tried to put some break points in the function in order to find out where uP crashes and I can note 3 different behaviours:

  • the program jumps to __mpyi_f5hw
  • the program jumps to __TI_ISR_TRAP
  • the program jumps to 0x0004 ( in the disassembly window I see 3FFF  JMP     (0x0004)
  • the program triggers the WatchDog and restart

I'm sure the problem is inside this routine but which is the best way to find out its root? 

Below there are my assumption.

  • The routine calls memset function to clear the buffer before the start-up operation
/*clear line*/
    for(tval=0; tval<MAX_lines; tval++) {
        watchdog();
        memset(&buffer.notepad[tval], '\0', sizeof(buffer.notepad[tval]));
    }

  • I have a function to write text:
void cmd_TEXT (unsigned int x, unsigned int y, unsigned int font, unsigned int opts, const char *t) {
    unsigned int lung=0;
    lung=strlen(t);
    write_COMMAND32(CMD_TEXT);
    write_COMMAND16(x);
    write_COMMAND16(y);
    write_COMMAND16(font);
    write_COMMAND16(opts);
    write_text(t, lung);
}

void write_text(const char *string, unsigned int longn) {
    const char dummy_byte=0x00;
    do {
        write_COMMAND8(*stringa);
        *string++;
    }
    while(*string!=0);
    if(longn>0) {
       do {
          write_COMMAND8(dummy_byte);
          longn++;
          }
      while ((longn%4)!=0);       //--> to load the correct value of the character on RAM_CMD the Offset must be a multiple of 4
    }
    if(longn==0) {
        write_COMMAND8(dummy_byte);
        write_COMMAND8(dummy_byte);
        write_COMMAND8(dummy_byte);
    }
}

Any advice and help would be really appreciated.
Thanks for the attention,

Best Regards,
Maria Angela

  • Hello,

    According to the thread below, MSP doesn't use memset for code size reasons and the memset won't work for the large code, small data model. I have a feeling this is another case where using certain C functions overwhelms the MCU due to its limited resources. For general debugging for these types of issues, makes sure your compiler optimizations are turned off and try commenting out certain lines of code until the issue goes away then work back from that.

    facing problem to use memset with msp430g2553

    Regards,

    James

  • Good morning James!

    thank you very much for your clear answer.

    I've replaced every memset function and I notice I still have the issue but this time is related to another function I wrote where I call

    strlen(string_pointer)

    Is it possible that I have the same issue not only for memset but also for the other function in string.h library?

    Best Regards, 

    Maria Angela

  • Hello,

    Does the issue go away when you remove the strlen() function too? If so, it's probably causing the issue. According to Jens-Michael Gross in the thread below, there may be a simpler, faster way than using the strlen() function.

    Needed help for using function of String in IAR.

    Regards,

    James

  • Good morning James,

    finally I find a solution to this issue.

    I think the root of the problem was the optimization level on CCS.

    I studied what every level means in terms of code optimization and I decided to disable it for the moment.

    I also created my own version of the functions 

    memcpy();
    strlen();

    to avoid any problem.

    I hope this would be helpful also for others,

    Thank you very much for your help and advice!

    Best Regards,

    Maria Angela

**Attention** This is a public forum