主题中讨论的其他器件:SysConfig、 CC2340R5
工具与软件:
SysConfig 版本1.21.1中未提供配置可访问性来配置来自外 设的事件以触发订阅者外设。
如果有任何方法(除了直接外设寄存器配置)可以这样做、请分享。
示例: 我需要 ADC 由计时器触发。
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
工具与软件:
SysConfig 版本1.21.1中未提供配置可访问性来配置来自外 设的事件以触发订阅者外设。
如果有任何方法(除了直接外设寄存器配置)可以这样做、请分享。
示例: 我需要 ADC 由计时器触发。
您好!
感谢您联系我们。
目前、CC2340R5上的 LGPTimer 不支持 ADC 触发。
我建议您参考 计时器驱动程序 doxygen https://software-dl.ti.com/simplelink/esd/simplelink_lowpower_f3_sdk/8.20.00.119/exports/docs/drivers/doxygen/html/_l_g_p_timer_l_p_f3_8h.html 中提供的周期性计时器示例
我希望这将有所帮助、
此致、
您好!
关于我的要求、
"配置周期性计时器中断->从计时器获取中断->在同一 ISR 中触发 ADC (单次)->获取周期性 ADC 读数"[/QUOT]您可以考虑使用以下代码片段。 我基本上采用了空示例、在 SysConfig 中添加了一个 ADC 和一个 LGPTimer 实例(我保留了默认命名)。 然后用以下内容替换了 empty.c 的所有内容:
/* * ======== empty.c ======== */ /* For usleep() */ #include <unistd.h> #include <stdint.h> #include <stddef.h> /* Driver Header files */ #include <ti/drivers/GPIO.h> // #include <ti/drivers/I2C.h> // #include <ti/drivers/SPI.h> // #include <ti/drivers/Watchdog.h> /* Driver configuration */ #include "ti_drivers_config.h" #include <ti/drivers/timer/LGPTimerLPF3.h> #include <ti/drivers/ADC.h> ADC_Handle adcHandle; LGPTimerLPF3_Handle lgptHandle; volatile uint_fast16_t adcValue; void timerCallback(LGPTimerLPF3_Handle lgptHandle, LGPTimerLPF3_IntMask interruptMask) { // interrupt callback code goes here. Minimize processing in interrupt. ADC_convert(adcHandle, &adcValue); } /* * ======== mainThread ======== */ void *mainThread(void *arg0) { ADC_init(); // initialize optional ADC parameters ADC_Params adc_params; ADC_Params_init(&adc_params); adc_params.isProtected = true; // Open ADC channels for usage adcHandle = ADC_open(CONFIG_ADC_0, &adc_params); LGPTimerLPF3_Params lgpt_params; uint32_t counterTarget; // Initialize parameters and assign callback function to be used LGPTimerLPF3_Params_init(&lgpt_params); lgpt_params.hwiCallbackFxn = timerCallback; // Open driver lgptHandle = LGPTimerLPF3_open(CONFIG_LGPTIMER_0, &lgpt_params); // Set counter target counterTarget = 48000 - 1; // 1 ms with a system clock of 48 MHz LGPTimerLPF3_setInitialCounterTarget(lgptHandle, counterTarget, true); // Enable counter target interrupt LGPTimerLPF3_enableInterrupt(lgptHandle, LGPTimerLPF3_INT_TGT); // Start counter in count-up-periodic mode LGPTimerLPF3_start(lgptHandle, LGPTimerLPF3_CTL_MODE_UP_PER); // Generate counter target interrupt every 1 ms forever while (1) { sleep(1); } }我希望这将有所帮助、
此致、