<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>memcpy usage landing in HardFault_Handler</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/33721/memcpy-usage-landing-in-hardfault_handler</link><description> 
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</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: memcpy usage landing in HardFault_Handler</title><link>https://community.arm.com/thread/107842?ContentTypeID=1</link><pubDate>Fri, 15 Aug 2014 11:05:12 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:02eae5d6-3cd3-424d-89ad-f567149621bb</guid><dc:creator>HansBernhard Broeker</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;Any idea why I am getting error?&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Most likely stack overflow.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: memcpy usage landing in HardFault_Handler</title><link>https://community.arm.com/thread/120400?ContentTypeID=1</link><pubDate>Fri, 15 Aug 2014 07:49:44 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:d147b7b5-8108-400d-8781-dcf4a8cd5b24</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
If ASCII is a character between &amp;#39;0&amp;#39; and &amp;#39;9&amp;#39;, then you need to take
(ASCII-&amp;#39;0&amp;#39;) as index into the array.&lt;/p&gt;

&lt;p&gt;
But why do you play around with all hard-coded sizes? Don&amp;#39;t you
believe in using&lt;/p&gt;

&lt;pre&gt;
#define CHAR_HEIGHT 100
#define CHAR_XBYTES 8
#define CHAR_SIZE (CHAR_HEIGHT*CHAR_XBYTES)
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
or&lt;/p&gt;

&lt;pre&gt;
enum {
    CharHeight = 100,
    CharXBytes = 8,
    CharSize = CharHeight*CharXBytes,
};
&lt;/pre&gt;

&lt;p&gt;
It really isn&amp;#39;t good to make use of magic values - and how will
you ever be able to find all places where you use a magic value, in
case you need to change from 800 to something else?&lt;/p&gt;

&lt;p&gt;
And is there a reason why you avoid sizeof(xxx)?&lt;/p&gt;

&lt;p&gt;
And why play with so nice variable names l, i, j, k? Wouldn&amp;#39;t x
and y or row, col be better names?&lt;/p&gt;

&lt;p&gt;
And why do you copy 800 bytes for every character you are going to
write - isn&amp;#39;t it enough to get a pointer to the bitmap instead of the
extra 800 byte large buffer[]?&lt;/p&gt;

&lt;pre&gt;
void Put7SegmentXL( uint16_t Xpos, uint16_t Ypos, uint8_t ASCI, uint16_t charColor, uint16_t bkColor )
{
    uint16_t dx=0, dy=0, xbytes=0;
    unsigned char tmp_char;
    unsigned *charmap = Get7SegmentXLCode(ASCII);
    for (dy=0; dy&amp;lt;CHAR_HEGIHT; ++dy) {
        for (xbytes=dx=0; xbytes&amp;lt;CHAR_XBYTES; xbytes++) {
            tmp_char = *charmap++;
            for (bit=0; bit&amp;lt;8; ++bit) {
                LCD_SetPoint( Xpos + dx++, Ypos + dy,
                    (tmp_char &amp;amp; (0x1&amp;lt;&amp;lt;bit)) ? charColor : bkColor);
            }
        }
    }
}
&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: memcpy usage landing in HardFault_Handler</title><link>https://community.arm.com/thread/118531?ContentTypeID=1</link><pubDate>Fri, 15 Aug 2014 05:33:52 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:eebe5800-7cd3-452c-87e6-57c11b757b48</guid><dc:creator>Westonsupermare Pier</dc:creator><description>&lt;p&gt;&lt;p&gt;
Because your code doesn&amp;#39;t make much sense, there&amp;#39;s insufficient
context, and your quite likely violating the bounds of the array, and
that SevenSegNumXLFont[ASCII] probably doesn&amp;#39;t provide the array
address you&amp;#39;re looking for.&lt;/p&gt;

&lt;p&gt;
What&amp;#39;s the range of ASCII? 0..9?&lt;br /&gt;
Are you trying to display a string?&lt;br /&gt;
How&amp;#39;s the function called?&lt;br /&gt;
What&amp;#39;s the expected behaviour?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: memcpy usage landing in HardFault_Handler</title><link>https://community.arm.com/thread/82082?ContentTypeID=1</link><pubDate>Fri, 15 Aug 2014 02:31:55 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:03cbadb0-bb9b-4231-a7bc-be45aecf8f2d</guid><dc:creator>Mohan Renganathan</dc:creator><description>&lt;p&gt;&lt;p&gt;
Code was right but by mistake I pasted another array declaration.
The correct one is pasted below. This is the one in the code.&lt;/p&gt;

&lt;pre&gt;
static const unsigned char SevenSegNumXLFont[10][800]={
.
.
}
&lt;/pre&gt;

&lt;p&gt;
You could see that from the name &amp;quot;SevenSegNumXLFont&amp;quot;&lt;br /&gt;
Sorry about that&lt;/p&gt;

&lt;p&gt;
Any idea why I am getting error?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: memcpy usage landing in HardFault_Handler</title><link>https://community.arm.com/thread/63061?ContentTypeID=1</link><pubDate>Fri, 15 Aug 2014 00:24:32 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:d04be3c4-69ca-4c4b-873c-1b6a55ee12ce</guid><dc:creator>HansBernhard Broeker</dc:creator><description>&lt;p&gt;&lt;p&gt;
How did you arrive at the conclusion that you should copy
&lt;b&gt;800&lt;/b&gt; bytes out of a &lt;b&gt;200&lt;/b&gt;-byte array?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>