stm32f1硬件仿真进入systeminit没有到main

  1. 设置Use MicroLIB
    在这里插入图片描述

  2. 用CubeMX生成的MDK工程文件替换,重新添加所需的.c文件,原因是使用了printf()函数。

  3. 用以下代码代替Use MicroLIB

#include "printf_redirect.h"

#include <stdio.h>

#if !defined(_MSC_VER)

#if defined(__CC_ARM)
#pragma import(__use_no_semihosting)
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6000000)
__asm(".global __use_no_semihosting\n\t");
#endif

#if defined(__ICCARM__) || defined(__CC_ARM)
struct __FILE
{
    int handle;
    /* Whatever you require here. If the only file you are using is */
    /* standard output using printf() for debugging, no file handling */
    /* is required. */
};
#endif

FILE __stdout; // required option '_DLIB_FILE_DESCRIPTOR' for IAR compiler
FILE __stdin;
FILE __stderr;

void _ttywrch(int ch)
{
    printf_putchar(ch);
}

void _sys_exit(int x)
{
    x = x;
}

int fputc(int ch, FILE *f)
{
    printf_putchar(ch);

    return ch;
}

int remove(const char *filename)
{
    return 0;
}

char *_sys_command_string(char *cmd, int len)
{
    return 0;
}

int _sys_tmpnam(char *name, int fileno, unsigned maxlength)
{
    return 0;
}

#endif

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值