cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4 MCU

Anonymous
Not applicable

For some reason this code gets stuck at sprintf in debug mode. Any tips? 

   

#include <project.h>
#include <stdio.h>

   

int main()
{
    CyGlobalIntEnable; /* Enable global interrupts. */
 
    UART_Start();
    
    char* str;
    sprintf(str, "Hello");

   


    for(;;)
    {
        UART_UartPutString(str);
    }
}

0 Likes
1 Solution
JoMe_264151
Expert II

Set heap size to 0x0200 (in cydwr System), set use newlib nano (build settings Linker)and allow for float formatting.

   

You defined str to be a pointer to char, but you did not allocate any memory for your string.

   

Better define

   

char str[80];   //  Maximum line length

   

 

   

 

   

Bob

View solution in original post

0 Likes
1 Reply
JoMe_264151
Expert II

Set heap size to 0x0200 (in cydwr System), set use newlib nano (build settings Linker)and allow for float formatting.

   

You defined str to be a pointer to char, but you did not allocate any memory for your string.

   

Better define

   

char str[80];   //  Maximum line length

   

 

   

 

   

Bob

View solution in original post

0 Likes