I need to use cJSON to parse the uart data. I found the file in SDK15.3 but how can I use the related function?
I need to use cJSON to parse the uart data. I found the file in SDK15.3 but how can I use the related function?
I think I found the reason. This issue can occur if the total number of blocks from XXS to XXL exceeds 255. This is independent of the block size, and I firmly believe that the size of each memory block I set is reasonable. Because, I use nrf_malloc to apply for the memory of the corresponding block size to determine whether to return null, and observe whether the number of successful applications corresponds to the number I set. The final result is correct. So how can I solve the HardFault_Handler caused by cJSON_CreateNumber?
Hi,
It's not clear to me.. you say that you solved the problem with nrf_malloc, and with malloc it doesn't crash. What IDE are you using? Could you show debug trace (disassembly, stack, registers) where hard fault occures?
Yes, there is no problem when parsing JSON data. But when I create JSON data, I will use cJSON_CreateNumber. So after I blocked all the other parts related to JSON parsing, I called cJSON_CreateNumber and found that as long as the total number of memory blocks from XXS to XXL exceeds 255, calling cJSON_CreateNumber will cause the program to die in HardFault_Handler. There is no log information (I didn't open men_manger module log)
Whether to use malloc is not the key, the key is that when I call nrf_mem_init, and the total number of memory blocks from XXS to XXL exceeds 255, calling cJSON_CreateNumber will cause the program to die in HardFault_Handler.
The IDE I am using is SES and KEIL, and I don't know how to display debug traces (disassembly, stack, registers) where hard faults occur. The end result is just the program stuck in HardFault_Handler