尝试了用scs里面的ledpwm例程实现自定义占空比的4通道pwm
请问怎么实现不同占空比的设置呢?更改了duty cycle和timer2的计数并没有发生改变?
Viki Shi:
建议用PWM driver做:e2e.ti.com/…/474000
Alvin Chen:
你有LP 板子吗?可以参考下面的程序 while (1) {UInt events = Event_pend(h_evnButtonPressed, Event_Id_NONE, EV_BTNS_MASK, BIOS_WAIT_FOREVER);// Increment the duty-cycle if BTN1 was pressedif (events & EV_BTN1_PRESSED){// Interrupt has to be enabled, as it was disabled by the Hwi callbackPIN_setConfig(h_buttonPins, PIN_BM_IRQ, Board_BTN1 | PIN_IRQ_NEGEDGE);dutyCycleExp = MIN(dutyCycleExp + 1, SCIF_LED_PWM_DUTY_CYCLE_EXP_MAX);}// Decrement the duty-cycle if BTN2 was pressedif (events & EV_BTN2_PRESSED){// Interrupt has to be enabled, as it was disabled by the Hwi callbackPIN_setConfig(h_buttonPins, PIN_BM_IRQ, Board_BTN2 | PIN_IRQ_NEGEDGE);dutyCycleExp = MAX(dutyCycleExp - 1, SCIF_LED_PWM_DUTY_CYCLE_EXP_MIN);}// Set new duty-cycle which is read by the Sensor Controller taskscifTaskData.ledPwm.cfg.dutyCycleExp = dutyCycleExp;}
Alvin Chen:
回复 Alvin Chen:
你好,上面的程序亲测可以正常调整占空比。
Zixuan Ding:
回复 Viki Shi:
请问用SCS能做吗
Zixuan Ding:
回复 Alvin Chen:
有板子的~请问一下这段代码是哪个源程序里面的呢 我想参考学习一下
Alvin Chen:
回复 Zixuan Ding:
是的,我上面贴出来的程序即Sensor controller studio 产生的
Zixuan Ding:
回复 Alvin Chen:
那请问这个占空比是在SCS里设还是在CCS里设
Alvin Chen:
回复 Zixuan Ding:
不懂您什么意思?这个跟工具没关系,直接修改程序即可。
scifTaskData.ledPwm.cfg.dutyCycleExp = dutyCycleExp;
Zixuan Ding:
回复 Alvin Chen:
不好意思请问一下,为什么我用SCS生成的文件没有您这一段代码,是在哪个文件里呢,我只有如图这些文件