This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

memcpy usage landing in HardFault_Handler

Hi,

I am using memcpy and it is not running and landing in HardFault_Handler.

I am trying to create a big font to display in TFT LCD.
Below is my scenario. Can somebody what I am missing here?

1. I have font data declared as below

static const unsigned char SevenSegNumFont[10][200]={
    .
    .
    };

2. Use below function to copy font data from flash to memory

void Get7SegmentXLCode(unsigned char* pBuffer,unsigned char ASCII)
    {
       memcpy(pBuffer,SevenSegNumXLFont[ASCII] ,800);
    }

3. Function in #2 above is called from below function

void Put7SegmentXL( uint16_t Xpos, uint16_t Ypos, uint8_t ASCI, uint16_t charColor, uint16_t bkColor )
{
        uint16_t i=0, j=0,k=0,l=0;
    unsigned char buffer[800], tmp_char;
    Get7SegmentXLCode(buffer,ASCI);
        for (l=0;l<100;l++)
        {
            for( i=0; i<8; i++ )
            {
                tmp_char = buffer[k];
                for( j=0; j<8; j++ )
                {
                    if( (tmp_char >> 7 - j) & 0x01 == 0x01 )
                    {
                        LCD_SetPoint( Xpos + (i*8+j), Ypos + l, charColor );
                    }
                    else
                    {
                        LCD_SetPoint( Xpos + (i*8+j), Ypos + l, bkColor );
                    }

                }
                        k++;
            }
        }
}

4. When I run these code, it does not run and while debugging I found the memcpy is landing in error in the marked line <-------

0x00006722 EA400301  ORR      r3,r0,r1
0x00006726 079B      LSLS     r3,r3,#30
0x00006728 D003      BEQ      0x00006732
0x0000672A E009      B        0x00006740
0x0000672C C908      LDM      r1!,{r3}
0x0000672E 1F12      SUBS     r2,r2,#4 <------------
0x00006730 C008      STM      r0!,{r3}
0x00006732 2A04      CMP      r2,#0x04
0x00006734 D2FA      BCS      0x0000672C
0x00006736 E003      B        0x00006740
0x00006738 F8113B01  LDRB     r3,[r1],#0x01
0x0000673C F8003B01  STRB     r3,[r0],#0x01
0x00006740 1E52      SUBS     r2,r2,#1
0x00006742 D2F9      BCS      0x00006738
0x00006744 4770      BX       lr

Processor is NXP LPC1768
I am using MDK-ARM 4.23

Regards,
M Mohan

Parents Reply Children
No data