Skip to content

Conversation

@ramya-subramanyam
Copy link
Collaborator

@ramya-subramanyam ramya-subramanyam commented Jun 30, 2025

By creating this pull request you agree to the terms in CONTRIBUTING.md.
https://github.com/Infineon/.github/blob/master/CONTRIBUTING.md
--- DO NOT DELETE ANYTHING ABOVE THIS LINE ---

adc_range

ADC resolution is set to 12 bit hardcoded and cannot be changed. But the range is between 0 to 2047 which is upto 11 bits. This is because in single ended mode, the range is between 0 to 2047 when Vref is connected to GND as we can see in the TRM attached in the screenshot.
Now we have the ADC read resolution implemented. Also the negative values should not appear but in case the VSSA fluctuation 0 to -Vref, negative value appears.

image

Signed-off-by: Ramya Subramanyam <ramya.subramanyam@infineon.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request implements a new read resolution API for the PSOC6 core while updating documentation to reflect the changes. Key changes include:

  • Updating the Arduino deviations documentation to explain ADC read resolution behavior.
  • Adding the analogReadResolution function and a resolution-mapping helper in cores/psoc6/analog_io.c.
  • Updating the Arduino.h header to expose the new analogReadResolution API.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
docs/arduino-deviations.rst Updates documentation to describe ADC read resolution
cores/psoc6/analog_io.c Implements analogReadResolution and maps ADC value
cores/psoc6/Arduino.h Adds prototype for analogReadResolution
Comments suppressed due to low confidence (1)

docs/arduino-deviations.rst:35

  • Clarify in the docs that increasing resolution by left shifting (appending zeros) scales the ADC value without improving intrinsic measurement accuracy, which may affect how downstream calculations interpret the value.
The default ADC_RESOLUTION is fixed at 11 bits (range: 0–2047) due to hardware limitations.

}

static inline uint32_t map_adc_value(uint32_t adc_value) {
uint8_t adc_res = ADC_RESOLUTION - 1; // 11-bit ADC resolution
Copy link

Copilot AI Jun 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider defining a separate constant (e.g. EFFECTIVE_ADC_RESOLUTION) rather than subtracting 1 from ADC_RESOLUTION to clearly differentiate between the hardware ADC width and the effective read resolution.

Suggested change
uint8_t adc_res = ADC_RESOLUTION - 1; // 11-bit ADC resolution
uint8_t adc_res = EFFECTIVE_ADC_RESOLUTION; // Effective ADC resolution

Copilot uses AI. Check for mistakes.
@ramya-subramanyam ramya-subramanyam merged commit cefead3 into main Jun 30, 2025
12 checks passed
@ramya-subramanyam ramya-subramanyam deleted the fix-adc-issues branch June 30, 2025 12:41
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.

5 participants