瑞萨单片机论坛
直播中

lustao

13年用户 474经验值
擅长:嵌入式技术
私信 关注

【RA-Eco-RA2E1-48PIN-V1.0开发板试用】3、第一个程序增加printf输出

续前【RA-Eco-RA2E1-48PIN-V1.0开发板试用】2、第一个程序

运行rasc.exe打开上次位置项目,

在Stacks项中 点击Stacks->New Stack->Connectivity -> UART (r_sci_uart)。未标题-1 拷贝.png

r_sci_uart配置如下;未标题-2 拷贝.png

未标题-2 拷贝.jpg

在bsp中设置heap为0x2000
未标题-3 拷贝.png

保存并生成配置,在keil中用microlib
未标题-4 拷贝.png

增加部分代码:

#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)
{
//	USART_SendData(DEBUG_USART, (unsigned char) ch);
//	
//	while (!(DEBUG_USART->SR & USART_FLAG_TXE));
//	
//	return (ch);
	        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;

}

/*******************************************************************************************************************//**
 * main() is generated by the RA Configuration editor and is used to generate threads if an RTOS is used.  This function
 * is called by main() when no RTOS is used.
 **********************************************************************************************************************/
void hal_entry(void)
{
    /* TODO: add your own code here */
	    /* Open the transfer instance with initial configuration. */
    err = R_SCI_UART_Open(&g_uart0_ctrl, &g_uart0_cfg);
    assert(FSP_SUCCESS == err);

while(1)



    {


    /* USER CODE BEGIN 2 */
    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);
    /* USER CODE END 2 */
    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下载1730081443839.jpg

重新设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
1730081994687.jpg

达到预期状态。

更多回帖

发帖
×
20
完善资料,
赚取积分