- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi there
I always used ADC Delta sigma. This is my firs time with Sar ADC.
I have attached a simple project where the minus Sar's input is hooked up to Vref/2
From a pot I change the + input volatge between Vssa and Vdda.
I don't know what I am missing but I expect get negative values when V+ - V- is negative and positive values when the diference is positive.
I just got values from 0 couts to 4095 counts when the positive input is from 0v to 3.3v ,in this case.
Please see attached project.
Thank you in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Alejandro,
The problem with your code is that ADC_SAR_1_SAR_WRK0_PTR register is not sign extended; the result is always unsigned. You can use ADC_SAR_1_GetResult16(); API inside the ISR which will return a signed result .
Best Regards,
VRS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Alejandro,
The problem with your code is that ADC_SAR_1_SAR_WRK0_PTR register is not sign extended; the result is always unsigned. You can use ADC_SAR_1_GetResult16(); API inside the ISR which will return a signed result .
Best Regards,
VRS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi vsrs
Thank you for your answer.
I missed the int16 ADC_GetResult16(void) API side effect.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
The result format from the SAR block is unsigned. Firmware manipulation is required to get it in 2's complement format.
If you look into the component API function- ADC_SAR_1_GetResult16(), it reads the result from a register pointed by ADC_SAR_1_SAR_WRK_PTR and subtracts (ADC_SAR_1_shift) from the result. This is to get the 2's complement form.
In your code, you can either subtract 0x800 from the result or use the component API function.
-Rajiv
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi rajiv
You help me again
I missed the int16 ADC_GetResult16(void) API side effect.
Up today I did like you suggested :
In your code, you can either subtract 0x800 from the result or use the component API function.
Thank you again.