This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

printf doesn't work when implemented in a function.

Hello,

In one of my codes, I use the printf function. It works properly when implemented in the int main(void), but when I try to use it in a static void NAME (void){} function the printf don't print anything over the uart.

Are there any know behaviours about this ?

Config : Segger Embedded Studio, SDKs v15.0, Windows 10, PCA10056 0.12.0 2018.9

Best regards,
Sylvain.

Parents
  • I managed to make it work. Try following these steps: 

    • Open the template project template_pca10056 in SDK v15.2.0
    •  Modify your main.c to the following:

    #include <stdbool.h>
    #include <stdint.h>
    
    #include "nrf.h"
    #include "nordic_common.h"
    #include "boards.h"
    
    static void awesome_function (void){
          printf("From function \r\n");
    }
    
    
    /**
     * @brief Function for application main entry.
     */
    int main(void)
    {
        printf("From main \r\n");
        awesome_function();
        while (true)
        {
            // Do nothing.
        }
    }

    I guess the problem is something else. If you upload your code I might be able to figure it out.

    Best regards, Simon

Reply
  • I managed to make it work. Try following these steps: 

    • Open the template project template_pca10056 in SDK v15.2.0
    •  Modify your main.c to the following:

    #include <stdbool.h>
    #include <stdint.h>
    
    #include "nrf.h"
    #include "nordic_common.h"
    #include "boards.h"
    
    static void awesome_function (void){
          printf("From function \r\n");
    }
    
    
    /**
     * @brief Function for application main entry.
     */
    int main(void)
    {
        printf("From main \r\n");
        awesome_function();
        while (true)
        {
            // Do nothing.
        }
    }

    I guess the problem is something else. If you upload your code I might be able to figure it out.

    Best regards, Simon

Children
Related