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文章
17317瀏覽量
352630
發布評論請先 登錄
相關推薦
【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診斷軟件已通過安全標準認證,因此可以直接集成到您的系統中。無需進行認證
芯海通用 MCU應用筆記 :在 IAR 及 MDK 開發環境下使用 printf 函數重定向移植差異指南
和調試中,printf 函數是常用的打印函數,通常通過 fputc 接口的重定向,即可以通過 printf 輸出串口的信息。
但在 IAR8.x 下,需要一些 IDE 的額外配置,MCU
發表于 05-16 11:56
芯海通用 MCU 應用筆記: C32F03x 系列快速應用指南
本應用筆記旨在指導用戶搭建 CS32F03x/F03x-RA 系列 MCU 開發環境并進行開發和調試,包括:軟件開發與移植、軟硬件注意事項、開發板說明、如何 Keil/IAR/GCC
發表于 05-16 11:29
瑞薩電子RA產品家族新增RA0E1 MCU產品組
瑞薩電子RA產品家族新增RA0E1 MCU產品組。RA0E1系列是一款低功耗、低成本微控制器,結合了32MHz Arm? Cortex?-M23內核和優化的外設功能。
瑞薩電子RA家族推出RA8系列高算力通用MCU
瑞薩電子RA家族推出RA8系列高算力通用MCU,是業界首款基于Arm? Cortex?-M85(CM85)內核的32位MCU,主頻高達480Mhz,超過3000 CoreMark跑分。
RA MCU中的CRC模塊和使用方法
瑞薩RA單片機硬件CRC計算單元采用固定的多項式發生器來計算8位或者32位數據的CRC校驗值,對數據傳輸或數據存儲的一致性、完整性進行驗證。這篇文章重點介紹RA MCU中的CRC模塊和使用方法。
發表于 02-26 11:45
?1062次閱讀
【AWTK開源智能串口屏方案】MCU SDK使用與編譯運行
代碼智能串口屏方案,本系列文章介紹如何從零開發HMI程序,包括搭建開發環境、創建HMI運行時工程、修改應用界面以及開發MCU程序。MCU端簡介相對于HMI端(
評論