板子到手,先验证一下点灯。
1、打开e2studio,新建工程:
2、选择工程存放的目录以及工程名称:
3、选择好芯片弄号,以及编译器以及下载调试器:
4、选择不需要RTOS
5、在配置中开启P103以及P112为输出模式:
6、保存并生成代码,打开hal_entry.c,并在void hal_entry(void)函数中添加如下代码
fsp_err_t err;
/*******************************************************************************************************************//**
* 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 */
err = R_IOPORT_Open(&g_ioport_ctrl, &g_bsp_pin_cfg);
while(1){
R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_01_PIN_03, 0);
R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_01_PIN_12, 1);
R_BSP_SoftwareDelay(1000, BSP_DELAY_UNITS_MILLISECONDS);
R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_01_PIN_03, 1);
R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_01_PIN_12, 0);
R_BSP_SoftwareDelay(1000, BSP_DELAY_UNITS_MILLISECONDS);
}
#if BSP_TZ_SECURE_BUILD
/* Enter non-secure code */
R_BSP_NonSecureEnter();
#endif
}
下载到开发板后,就可以成功的实现两个LED灯交替显示了: