主题中讨论的其他器件:MSPM0C1104
您好!
是否有芯片更新时间表来解决周期捕获问题?
谢谢。
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.
您好!
是否有芯片更新时间表来解决周期捕获问题?
谢谢。
你好,大脑,
器件修订没有当前时间表。 我建议使用软件权变措施来捕获周期。
如果希望缩短时钟周期以减少软件开销、我建议直接从寄存器获取该值、或简单地从 GPTIMER 寄存器中提取数据。 为计时器加载加载值也会发生同样的情况。
这里是一个我用于加快提取数据所需时间的示例。
/*
* Copyright (c) 2020, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "ti_msp_dl_config.h"
volatile uint32_t gCaptureCnt;
volatile bool gSynced;
volatile bool gCheckCaptures;
uint32_t gLoadValue;
volatile uint32_t start, end, calibration, time;
int main(void)
{
volatile static uint32_t pwmPeriod;
__attribute__((unused)) volatile static uint32_t pwmDuty;
SYSCFG_DL_init();
start = DL_SYSTICK_getValue();
end = DL_SYSTICK_getValue();
calibration = start - end;
/*
* This value is used to reload timer manually. Due to timer capture
* limitation
*/
gLoadValue = DL_TimerG_getLoadValue(CAPTURE_0_INST);
/* Initialize capture global states */
gSynced = false;
gCheckCaptures = false;
/*
* Forcing timers to halt immediately to prevent timers getting out of sync
* when code is halted
*/
DL_TimerG_setCoreHaltBehavior(
CAPTURE_0_INST, DL_TIMER_CORE_HALT_IMMEDIATE);
DL_TimerG_setCoreHaltBehavior(PWM_0_INST, DL_TIMER_CORE_HALT_IMMEDIATE);
NVIC_EnableIRQ(CAPTURE_0_INST_INT_IRQN);
DL_TimerG_startCounter(CAPTURE_0_INST);
DL_TimerG_startCounter(PWM_0_INST);
while (1) {
while (false == gCheckCaptures) {
__WFE();
}
gCheckCaptures = false;
/*
* Calculate PWM period and PWM duty cycle. IMPORTANT: These calculation
* assume timer is running in DOWN counting mode
*/
pwmPeriod = gLoadValue - gCaptureCnt;
pwmDuty = ((gLoadValue - DL_TimerG_getCaptureCompareValue(
CAPTURE_0_INST, DL_TIMER_CC_0_INDEX)) *
100) /
pwmPeriod;
__BKPT(0);
}
}
void CAPTURE_0_INST_IRQHandler(void)
{
switch (DL_TimerG_getPendingInterrupt(CAPTURE_0_INST)) {
case DL_TIMERG_IIDX_CC1_DN:
if (gSynced == true) {
start = DL_SYSTICK_getValue();
//Getting the data from the struct directly, saves clock cycles
gCaptureCnt = (CAPTURE_0_INST->COUNTERREGS.CC_01[1]) & GPTIMER_CC_01_CCVAL_MASK;
/*gCaptureCnt = DL_TimerG_getCaptureCompareValue(
CAPTURE_0_INST, DL_TIMER_CC_1_INDEX);*/
end = DL_SYSTICK_getValue();
gCheckCaptures = true;
} else {
gSynced = true;
}
/* Manual reload is needed to workaround timer capture limitation */
DL_TimerG_setTimerCount(CAPTURE_0_INST, gLoadValue);
time = start - end - calibration;
break;
case DL_TIMERG_IIDX_ZERO:
/* If Timer reaches zero then no PWM signal is detected and it
* requires re-synchronization
*/
gSynced = false;
break;
default:
break;
}
}
通过直接访问、您可以节省一些时钟周期、我们的 driverlib 可以灵活地输入(哪些计时器、通道等)、这可能会导致额外的时钟周期来处理此问题。 通过执行直接访问、您将节省处理时间。
此致、
卢克