Cortex M0 hardfault; BLC Huffman

149 views Asked by At

On my application I have a Cortex M0 running inside the nRF51422 IC from Nordic Semiconductor.

When trying to use the Basic Compression Library, I got LZ and Rice working, but Huffman_Compress gives me a Hardware Fault. I suspect that the processor is accessing a non-aligned memory address, but how to be sure?

Can you take a quick look on the code to see if you can find the error? Here is the code from the developer website. On this code, I tried printing stuff before the processor hanged using RTT, and it finished the _Huffman_Hist( in, sym, insize ); but didn't even enter the _Huffman_MakeTree( sym, &stream ); function.

Thanks in advance! =)

1

There are 1 answers

0
Turbo J On BEST ANSWER

You might see a stack overflow here. Huffman_Compress() needs a bit more than 1 KB, and _Huffman_MakeTree() more than 2 KB addidtional stack space, so you get ~3 KB total at this point.

The default linker scripts only allocates 2 KB for the stack, and most of this space is needed for soft device radio operations.