i added this function:
void LPTMR_DRV_DelayUs()
{
LPTMR_DRV_StartCounter(INST_LPTMR1);
while (!(LPTMR_DRV_GetCompareFlag(INST_LPTMR1)));
LPTMR_DRV_ClearCompareFlag(INST_LPTMR1);
LPTMR_DRV_StopCounter(INST_LPTMR1);
}
so when i first initilize the driver i do this:
lptmr_config_t lpTmr1_config0 =
{
.workMode = LPTMR_WORKMODE_TIMER,
.dmaRequest = false,
.interruptEnable = false,
.freeRun = false,
.compareValue = 100,
.counterUnits = LPTMR_COUNTER_UNITS_MICROSECONDS,
.clockSelect = LPTMR_CLOCKSOURCE_SIRCDIV2,
.prescaler = LPTMR_PRESCALE_2,
.bypassPrescaler = false,
.pinSelect = LPTMR_PINSELECT_TRGMUX,
.pinPolarity = LPTMR_PINPOLARITY_RISING,
};
LPTMR_DRV_Init(INST_LPTMR1, &lpTmr1_config0, false);
And then during the task running i do this:
(void)gpio_write(&gpio, false);
LPTMR_DRV_DelayUs();
(void)gpio_write(&gpio, true);
LPTMR_DRV_DelayUs();
I was supposed to get 100us delay between the gpio toggling, but instead i get 108us, and the 8 will always be there (ex. if i configure the timer for 50us i will get 58us etc)