AnsweredAssumed Answered

LPC1227 Hard Fault when reading value from pointer with valid address

Question asked by Milos Krizan on Jun 18, 2018
Latest reply on Jun 24, 2018 by Hui_Ma

Hi all,

 

I working on project with LPC1227. My application using many of libraries, previously created on linux.
These libraries were previously compiled and used on LPC1768 based project.
Now I have compiled these libraries for LPC1227.
When I run my test application, application will be stopped and stay dead.
I have debug, where is problem.

 

Problem occure when start condition with reading value of pointer *crc:

 

if(*crc == crc_calculated)  // Do this, will trigger HardFault_Handler(void) in cr_startup_lpc12xx.c file
{
    ...

 

All parts of used code are here:

 

typedef struct _ANB_SESSION_
{
    ...
    uint8_t rx_buff[40];
    ...
}
ANB_SESSION;

 

ANB_SESSION *anb_session;
uint16_t *crc;

 

crc = (uint16_t *)&(anb_session -> rx_buff[anb_session -> first_byte_datagram_index + sizeof(ANB_DATAGRAM_HEADER) + anb_datagram_header->Len]);

 

if(*crc == crc_calculated)  // Do this, will trigger HardFault_Handler(void) in cr_startup_lpc12xx.c file
{
    ...
}

 

Index of rx_buff in assignment is 28 and rx_buff is 40 bytes long.

 

Address filled in pointer crc is 0x10000329 and pointed value is 32292 decimal.
Local variable crc_calculated has same value (32292). Type of local variable crc_calculated is uint16_t.

 

When I click with cursor in debugger on variables in condition, displayed values are correct.
After do condition, then will be triggered HardFault_Handler.

 

I still using LPCxpresso v7.6.2 [Build 326] [2015-02-02] for LPC1227 and before LPC1768.

 

All libraries are only precompiled from LPC1768 to LPC1227 and used equaly.

 

 

Thank you for your help

 

Milos

Outcomes