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*/
/* TIM1 update interrupt processing */
LL_TIM_SetAutoReload(TIM1, xxx); // depending on my state machine
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?