Keil Print输出

  • 在keil中使能print输出

  • C++ASM标签添加DEBUG_ENABLE_SEMIHOST选项

  • 选中use microLib

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    #include "stdio.h"

    #define ITM_Port8(n) (*((volatile unsigned char *)(0xE0000000+4*n)))
    #define ITM_Port16(n) (*((volatile unsigned short*)(0xE0000000+4*n)))
    #define ITM_Port32(n) (*((volatile unsigned long *)(0xE0000000+4*n)))

    #define DEMCR (*((volatile unsigned long *)(0xE000EDFC)))
    #define TRCENA 0x01000000

    struct __FILE { int handle; /* Add whatever you need here */ };
    FILE __stdout;
    FILE __stdin;

    int fputc(int ch, FILE *f) {
    if (DEMCR & TRCENA) {
    while (ITM_Port32(0) == 0);
    ITM_Port8(0) = ch;
    }
    return(ch);
    }
  • Copyright: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
  • Copyrights © 2017-2020 Dock
  • Visitors: | Views:

请我喝杯咖啡吧~

支付宝
微信