续前【RA-Eco-RA2E1-48PIN-V1.0开发板试用】2、第一个程序
运行rasc.exe打开上次位置项目,
在Stacks项中 点击Stacks->New Stack->Connectivity -> UART (r_sci_uart)。
r_sci_uart配置如下;
在bsp中设置heap为0x2000
保存并生成配置,在keil中用microlib
增加部分代码:
#include "stdio.h"
FSP_CPP_HEADER
void R_BSP_WarmStart(bsp_warm_start_event_t event);
FSP_CPP_FOOTER
fsp_err_t err = FSP_SUCCESS;
unsigned char send_buff[100];
volatile bool uart_send_complete_flag = false;
void user_uart_callback (uart_callback_args_t * p_args)
{
if(p_args->event == UART_EVENT_TX_COMPLETE)
{
uart_send_complete_flag = true;
}
}
int fputc(int ch, FILE *f)
{
err = R_SCI_UART_Write(&g_uart0_ctrl, (uint8_t *)&ch, 1);
if(FSP_SUCCESS != err) __BKPT();
while(uart_send_complete_flag == false){}
uart_send_complete_flag = false;
return ch;
}
void hal_entry(void)
{
err = R_SCI_UART_Open(&g_uart0_ctrl, &g_uart0_cfg);
assert(FSP_SUCCESS == err);
while(1)
{
printf("Hello, i am %s\\n", "mculover666");
printf("Test int: i = %d", 100);
printf("Test float: i = %f", 1.234);
printf("Test hex: i = 0x%2x",100);
R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_01_PIN_04,BSP_IO_LEVEL_LOW );
R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_01_PIN_03, BSP_IO_LEVEL_LOW);
printf("[app info led off]");
R_BSP_SoftwareDelay(500, BSP_DELAY_UNITS_MILLISECONDS);
R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_01_PIN_04, BSP_IO_LEVEL_HIGH);
R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_01_PIN_03, BSP_IO_LEVEL_HIGH);
printf("[app info led on]");
R_BSP_SoftwareDelay(500, BSP_DELAY_UNITS_MILLISECONDS);
}
编译:
linking...
Program Size: Code=6604 RO-data=680 RW-data=8 ZI-data=10336
FromELF: creating hex file...
After Build - User command #1: cmd /c "start "Renesas" /w cmd /c ""E:\\lst\\ra0e1-20240827154516\\123\\new1\\FSP_Project\\rasc_launcher.bat" "E:\\lst\\ra0e1-20240827154516\\123\\new1\\FSP_Project\\rasc_version.txt" -nosplash --launcher.suppressErrors --gensmartbundle --compiler ARMv6 --devicefamily ra "E:\\lst\\ra0e1-20240827154516\\123\\new1\\FSP_Project\\configuration.xml" "E:\\lst\\ra0e1-20240827154516\\123\\new1\\FSP_Project\\Objects\\FSP_Project.axf" 2> "%TEMP%\\rasc_stderr.out"""
".\\Objects\\FSP_Project.axf" - 0 Error(s), 47 Warning(s).
Build Time Elapsed: 00:00:33
下生成FSP_Project.hex文件。
Renesas Flash Programmer下载
重新设boot引脚
resetprintf输出:
Hello, i am mculover666
Test int: i =
100Test float: i = 1.234000Test hex: i = 0x64[app info led off][app info led
on]Hello, i am mculover666
Test int: i = 100Test float: i = 1.234000Test hex: i = 0x64[app info led
off][app info led on]Hello, i am mculover666
Test int: i =
100Test float: i = 1.234000Test hex: i = 0x64[app info led off][app info led
on]Hello, i am mculover666
Test
int: i = 100Test float: i = 1.234000Test hex: i = 0x64[app info led off][app
info led on]Hello, i am mculover666
Test int: i =
100Test float: i = 1.234000Test hex: i = 0x64[app info led off][app info led
on]Hello, i am mculover666
Test int: i = 100Test float: i = 1.234000Test hex: i = 0x64[app info led
off][app info led on]Hello, i am mculover666
Test int: i = 100Test float: i =
1.234000Test hex: i = 0x64[app info led off]
com
达到预期状态。