Skip to content

Commit

Permalink
adding volatile to value where ADC output is stored to prevent compil…
Browse files Browse the repository at this point in the history
…er from code optimization which lead for wrong value returned by function (#29)

Co-authored-by: KajotSoft <[email protected]>
  • Loading branch information
krzysiekkajot and KajotSoft committed Nov 29, 2023
1 parent b9de789 commit 1d005bd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cores/nRF5/wiring_analog_nRF52.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ uint32_t analogRead( uint32_t ulPin )
uint32_t pin = SAADC_CH_PSELP_PSELP_NC;
uint32_t saadcResolution;
uint32_t resolution;
int16_t value = 0;
volatile int16_t value = 0;

if (ulPin >= PINS_COUNT) {
return 0;
Expand Down

0 comments on commit 1d005bd

Please sign in to comment.