/*FUNCTION********************************************************************* * * Function Name : PDB_DRV_SetTimerModulusValue * Description : Set the value of timer modulus. * *END*************************************************************************/ void PDB_DRV_SetTimerModulusValue(uint32_t instance, uint32_t value) { assert(instance < PDB_INSTANCE_COUNT); PDB_Type * base = g_pdbBase[instance]; PDB_HAL_SetTimerModulusValue(base, value); }
/************************************************************************* * Function Name: PDB_init * Parameters: none * Return: none * Description: PDB module initialization *************************************************************************/ void PDB_init(void) { pdb_timer_config_t pdbUserConfig; PDB_HAL_Init(PDB0_BASE_PTR); PDB_HAL_SetAdcPreTriggerOutputEnable(PDB0_BASE_PTR, 0, (1U<<0)|(1U<<1), true); PDB_HAL_SetAdcPreTriggerEnable(PDB0_BASE_PTR, 0, (1U<<0)|(1U<<1), true); PDB_HAL_SetAdcPreTriggerBackToBackEnable(PDB0_BASE_PTR, 0, (1U<<1), true); PDB_HAL_SetAdcPreTriggerDelayValue(PDB0_BASE_PTR, 0, 0, (PWM_MODULO / 6)); // Set load register mode pdbUserConfig.loadValueMode = kPdbLoadValueImmediately; // Select PDB external trigger source, it is from FTM0 pdbUserConfig.triggerInput = kPdbTrigger8; PDB_HAL_ConfigTimer(PDB0_BASE_PTR,&pdbUserConfig); PDB_HAL_Enable(PDB0_BASE_PTR); PDB_HAL_SetTimerModulusValue(PDB0_BASE_PTR, 0x7fff); PDB_HAL_SetLoadValuesCmd(PDB0_BASE_PTR); // Set load register mode pdbUserConfig.clkPreDiv = kPdbClkPreDivBy1; pdbUserConfig.loadValueMode = kPdbLoadValueAtNextTrigger; // Select PDB external trigger source, it is from FTM0 pdbUserConfig.triggerInput = kPdbTrigger8; pdbUserConfig.seqErrIntEnable = true; pdbUserConfig.clkPreMultFactor = kPdbClkPreMultFactorAs1; PDB_HAL_ConfigTimer(PDB0_BASE_PTR,&pdbUserConfig); PDB_HAL_SetLoadValuesCmd(PDB0_BASE_PTR); enable_irq(g_pdbIrqId[0]); set_irq_priority(g_pdbIrqId[0], ISR_PRIORITY_PDB0); }