Hi
Thanks for your answer but my LWIP implementation works just fine. It comes to the hardfault when i am trying to create a cJson object while LWIP is being polled.
I attached a minimized code snippet.
The first call of cJSON_CreateObject(...) work fine but not the 2nd inside the while.
I really hope, someone can help me here...
Thanks in advance!
int main(void) {
/* Init board hardware. */
BOARD_InitBootPins();
BOARD_InitBootClocks();
BOARD_InitBootPeripherals();
systick_init();
//init LWIP
mdioHandle.resource.csrClock_Hz = EXAMPLE_CLOCK_FREQ;
/* Network interface variables */
ip4_addr_t ipaddr, netmask, gw;
/* Set network address variables */
IP4_ADDR(&gw, 192,168,80,1);
IP4_ADDR(&ipaddr, 192,168,80,80);
IP4_ADDR(&netmask, 255,255,255,0);
/* The lwIP single-threaded core: initialize the network stack */
lwip_init();
ethernetif_config_t enet_config = {
.phyHandle = &phyHandle,
.macAddress = configMAC_ADDR,
.non_dma_memory = non_dma_memory,
};
netif_add(&netif, &ipaddr, &netmask, &gw, &enet_config, ethernetif0_init, ethernet_input);
netif_set_default(&netif);
netif_set_up(&netif);
ping_init();
//this call works just fine!
cJSON *json = cJSON_CreateObject();
cJSON_Delete(json);
struct timer t;
timer_set(&t, 2000);
while(1) {
/* Poll the driver, get any outstanding frames */
ethernetif_input(&netif);
if(timer_expired(&t))
{
//this call will end in a hardfault
cJSON *json = cJSON_CreateObject();
cJSON_Delete(json);
timer_restart(&t);
}
...
}
return 0 ;
}