AnsweredAssumed Answered

TPM级联问题

Question asked by 虹 姚 on Sep 16, 2018
Latest reply on Dec 8, 2018 by 虹 姚

我在使用KV1X系列MCU,想使用两个TPM级联生成一个32位定时器,TPM0自然计数到65535产生TOF标志,TPM1使用Counter trigger功能,我在配置了TPM1的CONF寄存器的CSOT位为1后,发现TPM1并没有受TPM0的溢出标志控制,这是为何?我使用TPM0溢出后会产生一个中断,在中断中清除溢出标志,下面是两个TPM的初始化配置:

const tpm_config_t TPM_0_config = {
.prescale = kTPM_Prescale_Divide_1,
.useGlobalTimeBase = false,
.triggerSelect = kTPM_Trigger_Select_0,
.enableDoze = false,
.enableDebugMode = false,
.enableReloadOnTrigger = false,
.enableStopOnOverflow = false,
.enableStartOnTrigger = false,
};

void TPM_0_init(void) {
TPM_Init(TPM_0_PERIPHERAL, &TPM_0_config);
TPM_SetTimerPeriod(TPM_0_PERIPHERAL, 65535);
TPM_EnableInterrupts(TPM_0_PERIPHERAL, kTPM_TimeOverflowInterruptEnable);
/* Interrupt vector TPM0_IRQn priority settings in the NVIC */
NVIC_SetPriority(TPM_0_IRQN, TPM_0_IRQ_PRIORITY);
/* Enable interrupt TPM0_IRQn request in the NVIC */
EnableIRQ(TPM_0_IRQN);
TPM_StartTimer(TPM_0_PERIPHERAL, kTPM_SystemClock);

}

 

 

const tpm_config_t TPM_1_config = {
.prescale = kTPM_Prescale_Divide_1,
.useGlobalTimeBase = true,
.triggerSelect = kTPM_Trigger_Select_8,
.enableDoze = false,
.enableDebugMode = false,
.enableReloadOnTrigger = false,
.enableStopOnOverflow = false,
.enableStartOnTrigger = true,
};

void TPM_1_init(void) {
TPM_Init(TPM_1_PERIPHERAL, &TPM_1_config);
TPM_SetTimerPeriod(TPM_1_PERIPHERAL, 65535);
TPM_StartTimer(TPM_1_PERIPHERAL, kTPM_SystemClock);
}

Outcomes