1Wire Driver implementation using STM32 Timer
Hello,
I'm using STM32L486 microcontroler and I have to implement eeprom 1Wire driver (DS2431).
As first implementation, I used _NOP operation to generate 1�s Delay.
It was working correctely and I was able to write and read data from my 1Wire eeprom.
As a second step, and to avoid using _NOP instrcution, I have to implement TimeBase timer example to generate 1Wire delays.
For example, to reset my eeprom bus, I have to implement timer using state machine as follow:
1. Set 1Wire GPIO to low level.
2. Program TimeBase to generate Interrupt after 500�s.
3. In timer Call back: (after 500�s)
- Stop the timer
- Configure GPIO to input mode
- re-configure timer for 70�s interrupt generation.
4. In timer call back (after 70�s)
- Stop the timer
- Read the input pin
- re-configure timer for 420�s interrupt generation.
5.
In timer call back (after 420�s)
Stop the timer.
State ready is set: 1wire is ready to read or write operation.
Unfortunately, reset pulse is not working correctly due to my implementation. and I am asking for re-configuring timebase on timerCall back function as follow :
void TIM1_UP_TIM16_IRQHandler (void)
{ /* Check whether update interrupt is pending */ if(LL_TIM_IsActiveFlag_UPDATE(TIM1) == 1) { /* Clear the update interrupt flag*/ LL_TIM_ClearFlag_UPDATE(TIM1); }/* TIM1 update interrupt processing */
DRV_1Wire_TimerCallBackLL(); }void DRV_1Wire_TimerCallBackLL(void)
{ LL_TIM_DisableIT_UPDATE(TIM1);LL_TIM_SetAutoReload(TIM1, xxx); // depending on my state machineLL_TIM_EnableIT_UPDATE(TIM1);
IncrementStateMachine(); // wait for the next state
}So my questions are:
1. Can I Re-configure my timer period on Timer call back function ?
2. How can I reduce more and more my timer period configuation?
3. there is better solution to calculate period on �s delay without using While instruction?
thnx.
#1wire #stm32l4-timer