This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

1us delay in low power mode

Hello

I am struggling for days, I can't any solution please check me!

Stm32L0xx serie microcontroller is running in low power with MSI clock source at 1048 KHz (1,048Mhz)

I try to read temperature sensor which is Ds18B20

And it requires us delay to read temp correctly. 

void delay_us(uint16_t us_value)
{
HTIMx.Instance->CNT = 0;
//when running at 1048Khz (us_value*95)/100
while (HTIMx.Instance->CNT < (us_value*95)/100);  
}

I am using Timer2 and my calculations is:

PSC = 0

ARR= 0xFFFF-1

in this case Timer2 clock frequency is 1.048Mhz and 0,95us each count.

But doesn't work and I can't read temp from 18B20

When microcontroller runs at 16 Mhz with PSC=16-1 ARR=0xFFFF-1 and other same codes it works smoothly...

Please check me...