Printf in Keil Studio Cloud Problem

Hi , I’m using NUCLEO-F429Zi and keil studio cloud
While i was using printf

 printf("Analog1 : %f \n",AnalogChannel[0]);

can’t working on TERATERM.But i was trying to in mbed-online compiler its working.
printf an integer to not working too but string working.
Can you help me ?

Hello,

what mean can’t working? - No output or wrong output? Do you use same MbedOS version in both?

BR , Jan

Hello Jan,
Thank you for fast response.I’m using mbed os 6.16.0 version .
I am using this code

/* mbed Microcontroller Library
 * Copyright (c) 2019 ARM Limited
 * SPDX-License-Identifier: Apache-2.0
 */
#include "mbed.h"
#include "iostream"
#include <list>
#include <iterator>
#include "PinDefinitions.h"

AnalogIn AIN0(ANALOG_IN_0);
AnalogIn AIN1(ANALOG_IN_1);
AnalogIn AIN2(ANALOG_IN_2);
AnalogIn AIN3(ANALOG_IN_3);
AnalogIn AIN4(ANALOG_IN_4);
AnalogIn AIN5(ANALOG_IN_0);

using namespace std;

class AnalogRead{
    public:
    float AnalogChannel[8];
    void Read(){
        AnalogChannel[0] = AIN0.read()*3.3;
       printf("Analog1 : %f \n",AnalogChannel[0]);
    }
};

int main()
{
    AnalogRead Analog;  //Obj Create
    
    while (true) {
        Analog.Read();
    }
}

This is what I’m getting from TERATERM terminal;

This is eazy. Look to this - mbed-os/README.md at master · ARMmbed/mbed-os (github.com)

So create or edit your mbed_app.json in root directory of your project.

{
    "target_overrides": {
        "*": {
            "target.printf_lib": "std"
        }
    }
}

BR, Jan

Btw that is not related to any tool what you use, but it is really about the version of MbedOS in your project. So I suppose you have MbedOS 5.15 in Online compiler and MbedOS 6.16 in KeilStudio. That makes the differentiation.

BR, Jan

Thanks a lot Jan you’ve been very helpful.