mirror of https://github.com/tinygo-org/tinygo.git
Browse Source
There was a very subtle bug in the ADC read code: it stores a pointer to a variable in a register, waits for the hardware to complete the read, and then reads the value again from the local variable. Unfortunately, the compiler doesn't know there is some form of synchronization happening in between. This can be fixed in roughly two ways: * Introduce some sort of synchronization. * Do a volatile read from the variable. I chose the second one as it is probably the least intrusive. We certainly don't need atomic instructions (the chip is single threaded), we just need to tell the compiler the value could have changed by making the read volatile.pull/3165/head
Ayke van Laethem
2 years ago
committed by
Ron Evans
1 changed files with 3 additions and 2 deletions
Loading…
Reference in new issue