【瑞萨RA8D1板卡】 调试串口输出
<p><span style="font-size:16px;">测试调试串口输出。</span></p><p> </p>
<p><span style="font-size:16px;"><strong>一、硬件电路</strong></span></p>
<p> </p>
<p><span style="font-size:16px;">与JLINK仿真器连接的串口USART3,电路图部分如下</span></p>
<p><span style="font-size:16px;"></span></p>
<p><span style="font-size:16px;">使用的端口是P408和P409。</span></p>
<p> </p>
<p><span style="font-size:16px;"><strong>二、串口配置</strong></span></p>
<p> </p>
<p><span style="font-size:16px;">2.1、配置串口端口和波特率</span></p>
<p><span style="font-size:16px;"></span></p>
<p> </p>
<p><span style="font-size:16px;">2.2、设置串口时钟</span></p>
<p><span style="font-size:16px;"></span></p>
<p> </p>
<p><strong><span style="font-size:16px;">三、代码</span></strong></p>
<p> </p>
<p><span style="font-size:16px;">3.1、bsp_debug_uart3.c</span></p>
<pre>
<code>#include "bsp_debug_uart.h"
void Debug_UART3_Init(void)
{
fsp_err_t err = FSP_SUCCESS;
err = R_SCI_B_UART_Open (&g_uart3_ctrl, &g_uart3_cfg);
assert(FSP_SUCCESS == err);
}
uint8_t uart_send_complete_flag = 0;
void debug_uart3_callback (uart_callback_args_t * p_args)
{
switch (p_args->event)
{
case UART_EVENT_RX_CHAR:
{
R_SCI_B_UART_Write(&g_uart3_ctrl, (uint8_t *)&(p_args->data), 1);
break;
}
case UART_EVENT_TX_COMPLETE:
{
uart_send_complete_flag = 1;
break;
}
default:
break;
}
}</code></pre>
<p><span style="font-size:16px;">3.2、bsp_debug_uart.h</span></p>
<pre>
<code>#ifndef __BSP_DEBUG_UART_H
#define __BSP_DEBUG_UART_H
#include "hal_data.h"
#include "stdio.h"
void Debug_UART3_Init(void);
#endif</code></pre>
<p> </p>
<p><span style="font-size:16px;">3.3、hal_entry.c</span></p>
<pre>
<code>#include "hal_data.h"
#include "led/led.h"
#include "debug_uart/bsp_debug_uart.h"
fsp_err_t err;
void R_BSP_WarmStart(bsp_warm_start_event_t event);
//extern bsp_leds_t g_bsp_leds;
/*******************************************************************************************************************//**
* @brief Blinky example application
*
* Blinks all leds at a rate of 1 second using the software delay function provided by the BSP.
*
**********************************************************************************************************************/
void hal_entry (void)
{
init_led();
Debug_UART3_Init();
while (1)
{
printf("https://bbs.eeworld.com.cn!\r\n");
/* if(R_BSP_PinRead (BSP_IO_PORT_00_PIN_08)==0)
{
led201_on();
}
else
{
led201_off();
}*/
/* Delay */
//R_BSP_SoftwareDelay(delay, bsp_delay_units);
R_BSP_SoftwareDelay(100, BSP_DELAY_UNITS_MILLISECONDS);
led201_on();
R_BSP_SoftwareDelay(100, BSP_DELAY_UNITS_MILLISECONDS);
led201_off();
}
}</code></pre>
<p> </p>
<p><strong><span style="font-size:16px;">四、运行结果</span></strong></p>
<p></p>
<p> </p>
<p><strong><span style="font-size:16px;">五、附件</span></strong></p>
<p> </p>
<div><span style="font-size:16px;">源代码:</span></div>
页:
[1]