D:\Software\SEGGER\JLink_V644b\Samples\RTT
D:\Software\SEGGER\JLink_V644b\Samples\RTT\SEGGER_RTT_V644b\RTT
RTT
分组,并将RTT
文件夹中的两个.c
文件添加进来。RTT
的头文件路径#include "sys.h"
#include "delay.h"
#include "usart.h"
#include "led.h"
#include "SEGGER_RTT.h"
int main(void)
{
HAL_Init(); //初始化HAL库
Stm32_Clock_Init(336,8,2,7); //设置时钟,168Mhz
delay_init(168); //初始化延时函数
LED_Init(); //初始化LED
while(1)
{
SEGGER_RTT_printf(0,"zhiguoxin666\r\n");
}
}
JLinkRTTViewer.exe
while(1)
{
SEGGER_RTT_SetTerminal(0);
SEGGER_RTT_printf(0,"zhiguoxin666,SEGGER RTT Terminal 0!\r\n");
SEGGER_RTT_SetTerminal(1);
SEGGER_RTT_printf(0,"zhiguoxin666,SEGGER RTT Terminal 1!\r\n");
SEGGER_RTT_SetTerminal(2);
SEGGER_RTT_printf(0,"zhiguoxin666,SEGGER RTT Terminal 2!\r\n");
delay_ms(1000);
}
while(1)
{
SEGGER_RTT_SetTerminal(0);
SEGGER_RTT_printf(0,RTT_CTRL_TEXT_RED"zhiguoxin666,SEGGER RTT Terminal 0!\r\n");
SEGGER_RTT_SetTerminal(1);
SEGGER_RTT_printf(0,RTT_CTRL_TEXT_GREEN"zhiguoxin666,SEGGER RTT Terminal 1!\r\n");
SEGGER_RTT_SetTerminal(2);
SEGGER_RTT_printf(0,RTT_CTRL_TEXT_BLUE"zhiguoxin666,SEGGER RTT Terminal 2!\r\n");
delay_ms(1000);
}
//重定义fputc函数
int fputc(int ch, FILE *f)
{
SEGGER_RTT_PutChar(0, ch);
return ch;
}
while(1)
{
printf("zhiguoxin666 ,printf SEGGER RTT Terminal!\r\n");
delay_ms(1000);
}
-END-
大家好,我是张巧龙,一名教电子的大学老师,欢迎关注!