UART print routine project works with online compiler, instead of Keil uvision4

26 Jan 2017

I prepared a simple Nucleo project with LED output, interrupt button, ADC, UART, I2C and SPI. The code works fine with online ARMCC compiler. However when I export the project to Keil uvision4, the code stops at Hardfault.

They I prepared the simplest code as following:

#include "mbed.h"

Serial pc(D1, D0);

int main()
{
    while(1){
        pc.printf("Hello World\r\n");
    }
}

When code runs into pc.printf(), when it hit BLX R1 instruction, it will go to an invalid address. I don't know what happens in the mbed platform. Does anyone knows about the issue?