DAPLink使用EventRecorder实现printf输出

发布于 2022-08-01  565 次阅读


sct文件增加EventRecorder.o文件

; *************************************************************
; *** Scatter-Loading Description File generated by uVision ***
; *************************************************************

LR_IROM1 0x08000000 0x00080000  {    ; load region size_region
  ER_IROM1 0x08000000 0x00080000  {  ; load address = execution address
   *.o (RESET, +First)
   *(InRoot$$Sections)
   .ANY (+RO)
   .ANY (+XO)
  }
  RW_IRAM1 0x20000000 0x0001C000  {  ; RW data
   .ANY (+RW +ZI)
  }
  RW_IRAM2 0x2001C000 UNINIT 0x00001000  {
    EventRecorder.o (+ZI)
  }
}
#include "cmsis_os2.h"                  // ARM::CMSIS:RTOS2:Keil RTX5
#include "stdio.h"
#include "EventRecorder.h"              // Keil.ARM Compiler::Compiler:Event Recorder
 
typedef struct {
  uint32_t hi;
  uint32_t low;
} MyType;
  
MyType mysymbol;
   
int main(void) {
  int       i;
  EventRecorderInitialize(EventRecordAll, 1);
  printf("EventRecord example\n");
  while (1) {
    for( i=0; i<=30; i++ ) {
      printf("The value of i is %d\n", i);
      mysymbol.hi = i*i;
      mysymbol.low = i;
    }
  }
}

一沙一世界,一花一天堂。君掌盛无边,刹那成永恒。