WIZnet Developer Forum

MALLOC Problem

Hello,

I wrote the simple program below. But always return ERROR. What am I doing wrong? Thanks! (I’m using WizWiki-7500P with lastes sources from github)

#include <stdio.h>
#include <stdlib.h>
#include "W7500x_uart.h"

int main()
{   
	  SystemInit();
    SysTick_Config((GetSystemClock()/1000));
    
  	S_UART_Init(9600);
    
    printf("System frequency: %d Hz\r\n", GetSystemClock());

    uint8_t * cnt = malloc(sizeof(uint8_t));
    if (NULL == cnt) {
        printf("ERROR");
    }
    else {
        printf("OK");
    }
    
    while(1) {     
    } 
}

Hello,

I apologize for the delay.
I modified the following and confirmed that it works well.
I moved the malloc declaration to the front and changed the uart baudrate to 115200.

Thankyou. :smiley:

	int main() {   

	uint8_t *cnt=malloc(sizeof(uint8_t));
	SystemInit();
	SysTick_Config((GetSystemClock()/1000));
    
	S_UART_Init(115200);
    
	printf("System frequency: %d Hz\r\n", 	GetSystemClock());
	
	if (NULL == cnt) {
    	    printf("ERROR");
    	}
    	else {
       	 printf("OK");
    	}
    	
   	 while(1) {     
    	} 
    }

Copyright © 2017 WIZnet Co., Ltd. All Rights Reserved.