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

LPC17xx imprecise error

I'm using array of buffer structure to store the data sent by external chip interfaced by SPI. it contains the data pointer and next pointer. The storage of data sent is triggered by the external GPIO interrupt. Inside "EINT1_IRQHandler" i'm calling a function to read a frame sent by chip.

typedef struct _buffer_t
{
    struct      _buffer_t *next;
    uint8_t          *dptr;
    uint8_t          len;
    uint8_t          buf[SIZE];
} buffer_t;

frame_read(buffer_t *buf)
{
                uint8_t i,length,*data=0,temp;

                if (!buf)
                  return;


                SSEL_CLR();
                spi_send(FR);
                length=spi_send(0);

                buf->dptr = &buf->buf[SIZE-length];
                for (i=0; i<length; i++)
                {
                temp = spi_send(0);
                *data++= temp;
                }
                SSEL_SET();
}

now at buf->dptr = &buf->buf[SIZE-length]; some times it gives me Imprecise error, according to different documents location of actual fault is hard to locate. So i used fault handler and MPU functions to debug this error.
The output of which is as follows

In Hard Fault Handler
SCB->HFSR = 0x40000000
Forced Hard Fault
SCB->CFSR = 0x00000082
Memory Management fault: Data access violation.
SCB->MMFAR = 0x0000000e
r0  = 0x00000077
r1  = 0x00000062
r2  = 0x00000006
r3  = 0x0000001f
r12 = 0x0fbbc8cb
lr  = 0x000020cb
pc  = 0x000020d8
psr = 0x21000023


now according to this there is data access violation at memory address 0x0000000e, which is part of 512 k flash memory. Flash memory is used for storage of program instructions and constant data types. I think buffer structure should be stored in the SRAM.

  • "I think buffer structure should be stored in the SRAM."

    Exactly - so fix your bugs where you make use of a pointer that hasn't been initialized, or where you use index outside bounds resulting in memory overwrites resulting in broken pointers.

    How clever do you think it is to make use of a NULL pointer in your code. Did you totally forget to debug these few lines of code, while looking at the contents of your variables?

    By the way - why are you aligning your data in the last part of the buffer?