Skip to content

Conversation

@ondras12345
Copy link
Contributor

When trying to read temperature from a DHT11 with the sensor disconnected, the program would encounter an infinite loop in DHT::expectPulse, because count would keep overflowing.

This PR changes the preprocessor #if expression so that if F_CPU == 0L is true (which it is in my case with STM32F103C8. I think F_CPU contains the name of a variable), 32 bits is allocated for count instead of the insufficient 16 bits.

This could potentially break platforms where F_CPU is also evaluated to 0 by the preprocessor, but working with an uint32_t makes the code run too slow. A less intrusive fix would be to add || defined(ARDUINO_BLUEPILL_F103C8) instead. However, that would not fix the problem for other platforms like STM32F401, where it is also present.

When trying to read temperature from a DHT11 when the sensor was
disconnected, the program would encounter an infinite loop in
DHT::expectPulse, because count would keep overflowing.
@ladyada ladyada merged commit 5273ef0 into adafruit:master Jun 26, 2022
@ladyada
Copy link
Member

ladyada commented Jun 26, 2022

thanks!

@ondras12345 ondras12345 deleted the unknown-F_CPU branch June 26, 2022 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants