static void InitTimer(void) { TPM_PDD_WriteStatusControlReg(TPM0_DEVICE, 0); /* init timer status and control register */ TPM_PDD_InitializeCounter(TPM0_DEVICE); /* reset timer counter */ TPM_PDD_WriteModuloReg(TPM0_DEVICE, TPM_OVL_TICKS); /* set overflow to 1.25 us */ TPM_PDD_WriteChannelValueReg(TPM0_DEVICE, 0, TPM_CH0_TICKS); /* channel 0 match at 0.4 us */ TPM_PDD_WriteChannelValueReg(TPM0_DEVICE, 1, TPM_CH1_TICKS); /* channel 1 match at 0.8 us */ }
/* ===================================================================*/ LDD_TError TU1_SetOffsetTicks(LDD_TDeviceData *DeviceDataPtr, uint8_t ChannelIdx, TU1_TValueType Ticks) { (void)DeviceDataPtr; /* Parameter is not used, suppress unused argument warning */ /* Parameter test - this test can be disabled by setting the "Ignore range checking" property to the "yes" value in the "Configuration inspector" */ if (ChannelIdx > LAST_CHANNEL) { /* Is the channel index out of range? */ return ERR_PARAM_INDEX; /* If yes then error */ } if ((ChannelMode[ChannelIdx]) != 0U) { /* Is the channel in compare mode? */ return ERR_NOTAVAIL; /* If not then error */ } TPM_PDD_WriteChannelValueReg(TPM0_BASE_PTR, ChannelDevice[ChannelIdx], (uint16_t)Ticks); return ERR_OK; /* OK */ }
static void TMR_SetTimerValue(uint32_t val) { TPM_PDD_WriteModuloReg(TPM0_BASE_PTR, val); /* set period of TPM0 */ TPM_PDD_WriteChannelValueReg(TPM0_BASE_PTR, 1, val/2); /* channel 1: PWM low 50% */ }
static void InitTimer(void) { TPM_PDD_WriteModuloReg(TPM0_BASE_PTR, TICKS_PERIOD); /* set period */ TPM_PDD_WriteChannelValueReg(TPM0_DEVICE, 1, 0); /* PWM low, zero duty */ TPM_PDD_EnableChannelDma(TPM0_DEVICE, 1); /* enable DMA for channel */ }