关于TMS570LS3137的PWM使用
如何创建工程在《 点亮LED灯(TMDS570LS31HDK)》中已经介绍了,现在就不赘述了。
1.如何配置HCG,同样使能GIO,HET1
2.配置HET1,选择pwm0通道,设置闪烁频率,使能。如下图所示
2选择pin0,配置为输出模式
配置完成,生成代码。
接下来编写sys_main.c文件
/* USER CODE BEGIN (1) */
#include "system.h"
#include "het.h"
/* USER CODE END */
/** @fn void main(void)
* @brief Application main function
* @note This function is empty by default.
*
* This function is called after startup.
* The user can use this function to implement the application.
*/
/* USER CODE BEGIN (2) */
/* USER CODE END */
int main(void)
{
/* USER CODE BEGIN (3) */
hetInit();
pwmSetDuty(hetRAM1,pwm0,30);
pwmStart(hetRAM1,pwm0);
while(1);
/* USER CODE END */
return 0;
}
编译烧录,重启开发板后看到D5 指示灯根据设定频率闪烁。