RA MCU 生態工作室致力于構建一個完善的 RA 生態,這將會是一個好玩有趣的開放社區,也提供各種RA相關問題的解決方法。
1.概述
通過RASC創建一個串口工程,具體配置如下,用戶可以根據自己定義來配置串口相關的基本參數。
2.創建工程
STEP1:RASC創建工程

STEP2:選芯片型號跟IDE類型

STEP3:選擇芯片型號

STEP4:選擇無操作系統

STEP5:勾選確認工程

STEP6:配置串口號跟IO口

STEP7:添加串口驅動

STEP8:配置串口

STEP9:配置串口基本屬性

STEP10:生成工程

3.代碼
STEP11:打開工程

STEP12:添加代碼

STEP13:具體代碼如下
void hal_entry( void )
{
/* TODO: add your own code here */
fsp_err_t err = R_SCI_UART_Open( &g_uart9_ctrl, &g_uart9_cfg );
assert( FSP_SUCCESS == err );
while ( true )
{
printf( "Hello RA MCU \r\n" );
}
#if BSP_TZ_SECURE_BUILD
/* Enter non-secure code */
R_BSP_NonSecureEnter();
#endif
}
STEP14:添加頭文件跟串口回調函數

STEP15:具體代碼如下
#include "hal_data.h"
#include "stdio.h"
FSP_CPP_HEADER
void R_BSP_WarmStart( bsp_warm_start_event_t event );
FSP_CPP_FOOTER
uint8_t g_transfer_complete = 0;
void g_uart9_cb( uart_callback_args_t* p_args )
{
/* Handle the UART event */
switch ( p_args->event )
{
/* Received a character */
case UART_EVENT_RX_CHAR:
{
break;
}
/* Receive complete */
case UART_EVENT_RX_COMPLETE:
{
break;
}
/* Transmit complete */
case UART_EVENT_TX_COMPLETE:
{
g_transfer_complete = 1;
break;
}
default:
{
}
}
}
STEP16:添加打印接口重定向代碼,具體如下
/*******************
*
* Copyright 1998-2017 IAR Systems AB.
*
* This is a template implementation of the "__write" function used by
* the standard library. Replace it with a system-specific
* implementation.
*
* The "__write" function should output "size" number of bytes from
* "buffer" in some application-specific way. It should return the
* number of characters written, or _LLIO_ERROR on failure.
*
* If "buffer" is zero then __write should perform flushing of
* internal buffers, if any. In this case "handle" can be -1 to
* indicate that all handles should be flushed.
*
* The template implementation below assumes that the application
* provides the function "MyLowLevelPutchar". It should return the
* character written, or -1 on failure.
*
********************/
#include
#pragma module_name = "?__write"
int MyLowLevelPutchar(int x)
{
R_SCI_UART_Write(&g_uart9_ctrl, (uint8_t *)&x, 1);
while(g_transfer_complete == 0);
g_transfer_complete = 0;
return x;
}
/*
* If the __write implementation uses internal buffering, uncomment
* the following line to ensure that we are called with "buffer" as 0
* (i.e. flush) when the application terminates.
*/
size_t __write(int handle, const unsigned char * buffer, size_t size)
{
/* Remove the #if #endif pair to enable the implementation */
#if 1
size_t nChars = 0;
if (buffer == 0)
{
/*
* This means that we should flush internal buffers. Since we
* don't we just return. (Remember, "handle" == -1 means that all
* handles should be flushed.)
*/
return 0;
}
/* This template only writes to "standard out" and "standard err",
* for all other file handles it returns failure. */
if (handle != _LLIO_STDOUT && handle != _LLIO_STDERR)
{
return _LLIO_ERROR;
}
for (/* Empty */; size != 0; --size)
{
if (MyLowLevelPutchar(*buffer++) < 0)
{
return _LLIO_ERROR;
}
++nChars;
}
return nChars;
#else
/* Always return error code when implementation is disabled. */
return _LLIO_ERROR;
#endif
}
4.工程配置
STEP17:工程配置

STEP18:彈出如下窗口

5.結果
STEP19:接上串口工具,打印如下

聲明:本文內容及配圖由入駐作者撰寫或者入駐合作網站授權轉載。文章觀點僅代表作者本人,不代表電子發燒友網立場。文章及其配圖僅供工程師學習之用,如有內容侵權或者其他違規問題,請聯系本站處理。
舉報投訴
-
mcu
+關注
關注
146文章
17851瀏覽量
360702
發布評論請先 登錄
相關推薦
熱點推薦
【RA4L1-SENSOR】+ RA4L1-SENSOR開發版之使用Jlink的RTT打印功能代替串口
上一篇帖子中我已經實現了板子上的串口USART9進行輸出打印,這篇帖子我采用另外一種串口打印來實現,這是瑞薩官網實現的最主要打印調試手段,那
發表于 06-09 09:03
【RA4L1-SENSOR】+ RA4L1-SENSOR開發版串口打印功能printf實現
很高興收到瑞薩RA生態工作室給與試用的RA4L1-SENSOR開發板,本期就來講解使用RA4L1-SENSOR開發板實現串口打印功能!
1。
發表于 06-08 15:01
【RA-Eco-RA4M2開發板評測】使用Jlink的RTT來實現串口打印功能
使用RTT代替UART,把你的JLink變成串口調試助手,不知道大家在單片機開發中是如何打印調試信息的,大多數應該是用串口調試打印吧,在大多數的情況下,一般在制板和寫代碼時都會預留
發表于 04-30 12:19
【RA-Eco-RA4M2開發板評測】RA-Eco-RA4M2 串口通信
的電平不同,因此要想MCU和PC通信,需要以USB轉串口的芯片,板載的芯片是CH340G,連接是MCU的SCI9。
3 串口發送實現
3.1 RA
發表于 04-27 23:23
【RA-Eco-RA4M2開發板評測】RA-Eco-RA4M2 Keil 開發環境搭建
開發環境:
IDE:MKD 5.38a
Renesas RA Smart Configurator:v5.1.0
開發板:RA-Eco-RA4M2
MCU:R7FA4M2AD3CFP
瑞薩電子
發表于 04-27 22:54
【RA-Eco-RA4M2開發板評測】1 RA4M2開發環境搭建
開發環境:
IDE:MKD 5.38a
Renesas RA Smart Configurator:v5.1.0
開發板:RA-Eco-RA4M2
MCU:R7FA4M2AD3CFP
瑞薩電子
發表于 04-25 22:38
【瑞薩RA2L1入門學習】02. 串口打印 ADC 檢測電壓
\");就會在串口輸出Hello RA MCU!當然了,在這之前需要做一些配置才能打印,這里就不過多介紹了。可以看到串口
發表于 03-07 11:52
基于瑞薩RA0E1開發板的ThreadX實時操作系統串口回顯測試
感謝立創提供測試機會,學到RA0及瑞薩MCU的相關使用。使用瑞薩FSP庫和配置工具大大簡化了開發過程。掌握相關函數的功能,如打開串口、設置串口參數、讀取和寫入

【RA-Eco-RA4E2-64PIN-V1.0開發板試用】串口打印功能
剛剛點燈完畢,現在來實現RA4E2的串口打印功能,先打開原理圖,我們看到
串口使用的是P109和P110兩個IO口,然后我們來進行配置
先打開
RA
發表于 12-13 13:08
【RA-Eco-RA2E1-48PIN-V1.0開發板試用】(第二篇)串口打印+SPI_OLED顯示
串口打印
想要使用微庫就必須將主堆棧設置大于0x1000(4K),就是這個東西,之前沒有注意一直編譯報錯[難過]
通過手冊可以得知R7FA2E1A72DFL并沒有獨立的UART,而是使用的SCI
發表于 11-09 01:30
【RA-Eco-RA2E1-48PIN-V1.0開發板試用】使用Jlink RTT完成printf打印功能
很榮幸收到瑞薩的RA2E1超低功耗開發板,現在開始寫第一篇相關的試用報告,看到別人已經用RA2E1的串口實現了printf打印功能,我就不重復了,下面我就使用Jlink自帶的RTT來實
發表于 10-31 21:00
【GD32 MCU 入門教程】一、GD32 MCU 開發環境搭建(2)使用 IAR 開發 GD32
GD32系列為通用型MCU,所以開發環境也可以使用通用型的IDE,目前使用較多的是KEIL、IAR、 GCC和Embedded Builder,客戶可以根據個人喜好來選擇相應的開發環境。

RA系列MCU Self-Test軟件包介紹
下面介紹一下瑞薩自檢軟件套件。該軟件包包括RA系列MCU診斷軟件、安全手冊、用戶指南和功能安全證書。RA系列MCU診斷軟件已通過安全標準認證,因此可以直接集成到您的系統中。無需進行認證

評論