2017-04-10 02:50 AM
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)
4. In timer call back (after 70�s)
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-timer2017-04-10 03:24 AM
You can use a 2-channel timer. One channel will generate the waveforem, the other channel captures the rising edge. Nut/OS
https://svn.code.sf.net/p/ethernut/code/trunk
uses this approach in nut/arch/cm3/dev/stm/stm32_owitim.c.
2017-04-11 02:13 AM
Hello,
Do you know this application note 214 from Maxim:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/214
' Using a UART to Implement a 1-Wire Bus Master ' I used this from a STM32F429 to DS2431 Regards