7
/* Initializes the module. */
err = R_AGT_Open(&g_timer0_ctrl, &g_timer0_cfg);
/* Handle any errors. This function should be defined by the user. */
assert(FSP_SUCCESS == err);
/* Start the timer. */
(void) R_AGT_Start(&g_timer0_ctrl);
err = R_AGT_PeriodSet(&g_timer0_ctrl, 2400);//频率
assert(FSP_SUCCESS == err);
R_BSP_SoftwareDelay (20, BSP_DELAY_UNITS_MILLISECONDS);//不加延时可能会设置不成功
err = R_AGT_DutyCycleSet(&g_timer0_ctrl, 1200, AGT_OUTPUT_PIN_AGTOA);//占空比
assert(FSP_SUCCESS == err);
err = R_AGT_DutyCycleSet(&g_timer0_ctrl, 720, AGT_OUTPUT_PIN_AGTOB);//占空比
assert(FSP_SUCCESS == err);
err = R_AGT_Reset(&g_timer0_ctrl);
assert(FSP_SUCCESS == err);
(void) R_AGT_Close(&g_timer0_ctrl);
void hal_entry(void)
{
/* TODO: add your own code here */
fsp_err_t err = FSP_SUCCESS;
/* Initializes the module. */
err = R_AGT_Open(&g_timer0_ctrl, &g_timer0_cfg);
/* Handle any errors. This function should be defined by the user. */
assert(FSP_SUCCESS == err);
R_BSP_SoftwareDelay (5, BSP_DELAY_UNITS_MILLISECONDS);
/* Start the timer. */
(void) R_AGT_Start(&g_timer0_ctrl);
R_BSP_SoftwareDelay (5, BSP_DELAY_UNITS_MILLISECONDS);
(void) R_AGT_Close(&g_timer0_ctrl);
#if BSP_TZ_SECURE_BUILD
/* Enter non-secure code */
R_BSP_NonSecureEnter();
#endif
}
void hal_entry(void)
{
/* TODO: add your own code here */
fsp_err_t err = FSP_SUCCESS;
/* Initializes the module. */
err = R_AGT_Open(&g_timer0_ctrl, &g_timer0_cfg);
/* Handle any errors. This function should be defined by the user. */
assert(FSP_SUCCESS == err);
/* Start the timer. */
(void) R_AGT_Start(&g_timer0_ctrl);
err = R_AGT_PeriodSet(&g_timer0_ctrl, 2400);//频率
assert(FSP_SUCCESS == err);
R_BSP_SoftwareDelay (20, BSP_DELAY_UNITS_MILLISECONDS);//不加延时可能会设置不成功
err = R_AGT_DutyCycleSet(&g_timer0_ctrl, 1200, AGT_OUTPUT_PIN_AGTOA);//占空比
assert(FSP_SUCCESS == err);
err = R_AGT_DutyCycleSet(&g_timer0_ctrl, 720, AGT_OUTPUT_PIN_AGTOB);//占空比
assert(FSP_SUCCESS == err);
#if BSP_TZ_SECURE_BUILD
/* Enter non-secure code */
R_BSP_NonSecureEnter();
#endif
}
原创:By RA_Billy Xiao
原文标题:瑞萨e2studio----定时器AGT配置PWM输出
文章出处:【微信公众号:RA生态工作室】欢迎添加关注!文章转载请注明出处。
全部0条评论
快来发表一下你的评论吧 !