/**
* These arguments were used when this file was generated. They will be automatically applied on subsequent loads
* via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments.
*/
// @cliArgs --device "MSPM0L130X" --package "VQFN-32(RHB)" --part "Default"
// @cliArgs --board /ti/boards/LP_MSPM0L1306 --rtos nortos
/**
* Import the modules used in this configuration.
*/
const PWM = scripting.addModule("/ti/driverlib/PWM", {}, false);
const PWM1 = PWM.addInstance();
/**
* Write custom configuration values to the imported modules.
*/
PWM1.$name = "PWM_0";
PWM1.clockPrescale = 256;
PWM1.timerCount = 2000;
PWM1.timerStartTimer = true;
PWM1.interrupts = ["CC0_DN_EVENT","LOAD_EVENT"];
PWM1.ccIndex = [1];
PWM1.peripheral.$assign = "TIMG0";
PWM1.PWM_CHANNEL_1.$name = "ti_driverlib_pwm_PWMTimerCC0";
PWM1.PWM_CHANNEL_1.dutyCycle = 10;
const Board = scripting.addModule("/ti/driverlib/Board", {}, false);
const SYSCTL = scripting.addModule("/ti/driverlib/SYSCTL", {}, false);
#include "ti_msp_dl_config.h"
int pwm_count = 1800; // initial ccr count based on 10% duty cycle
int dc = 10; // initialized to 10 % duty cycle
int mode = 1; // 1 = up (will indicate you need to increase dc), 0 = down (will
// decrease dc)
int main(void) {
SYSCFG_DL_init();
NVIC_EnableIRQ(PWM_0_INST_INT_IRQN);
DL_TimerG_startCounter(PWM_0_INST);
while (1) {
__WFI();
}
}
void PWM_0_INST_IRQHandler(void) {
switch (DL_TimerG_getPendingInterrupt(PWM_0_INST)) {
case DL_TIMER_IIDX_LOAD:
if (dc <= 10) {
mode = 1;
} // if reached lowest dc (10%), increase dc
else if (dc >= 90) {
mode = 0;
} // if reached highest dc (90%), decrease dc
if (mode) {
pwm_count -= 20;
dc += 1;
} // up
if (!mode) {
pwm_count += 20;
dc -= 1;
} // down
DL_TimerG_setCaptureCompareValue(PWM_0_INST, pwm_count,
DL_TIMER_CC_1_INDEX); // update ccr1 value
break;
default:
break;
}
}
引用: Jacktang 发表于 2023-11-12 08:22 新款CCS Theia 1.1.0还不支持这个功能(软件里和文档全文搜索都没有找到),需要安装传统版的CCS。 &nbs ...
就叫ccs,基于Eclipse的版本。Theia太新了,这个功能还没集成进去
引用: x1816 发表于 2023-11-12 11:25 就叫ccs,基于Eclipse的版本。Theia太新了,这个功能还没集成进去
原来这样啊,这Theia还真不了解