- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
in my project I'd like to add interrupt in ADC SAR, but I receive the following error:
Why ?
Best regards
LuBe
Solved! Go to Solution.
- Labels:
-
PSoC 4 MCU
- Tags:
- psoc4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Since PSoC 41xx does not have UDB, internal wiring connection is pretty limited.
Although I tried with SmartIO I could not find a way to graphically connect sdone to isr.
So I tried another approach, using firmware
#include "project.h"
volatile int adc_done = 0 ;
CY_ISR(my_adc_isr)
{
uint32 intr_status;
/* Read interrupt status register */
intr_status = ADC_SAR_INTR_REG;
adc_done = 1 ;
/* Clear handled interrupt */
ADC_SAR_INTR_REG = intr_status;
}
int main(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
ADC_Start() ;
ADC_IRQ_StartEx(my_adc_isr) ;
ADC_StartConvert() ;
for(;;)
{
if (adc_done) {
adc_done = 0 ;
ADC_StartConvert() ;
// CyDelay(1000) ;
}
}
}
I tried this with CY8CKIT-149 (CY8C4147AZI-S475), hopefully this trick works with your device, too.
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Since PSoC 41xx does not have UDB, internal wiring connection is pretty limited.
Although I tried with SmartIO I could not find a way to graphically connect sdone to isr.
So I tried another approach, using firmware
#include "project.h"
volatile int adc_done = 0 ;
CY_ISR(my_adc_isr)
{
uint32 intr_status;
/* Read interrupt status register */
intr_status = ADC_SAR_INTR_REG;
adc_done = 1 ;
/* Clear handled interrupt */
ADC_SAR_INTR_REG = intr_status;
}
int main(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
ADC_Start() ;
ADC_IRQ_StartEx(my_adc_isr) ;
ADC_StartConvert() ;
for(;;)
{
if (adc_done) {
adc_done = 0 ;
ADC_StartConvert() ;
// CyDelay(1000) ;
}
}
}
I tried this with CY8CKIT-149 (CY8C4147AZI-S475), hopefully this trick works with your device, too.
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Moto,
okay, I will try that solution.
Why Does the ADC max value is 2047 with 12bit risolution (12 bit = 4095) ?
Best regards
LuBe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear LuBe-san,
> Why Does the ADC max value is 2047 with 12bit risolution (12 bit = 4095) ?
The variable type is singed, so with 12bit it can represent -2048 to 2047.
And, yes, sometimes ADC returns a negative value, so the type needs to be signed.
Best Regards,
13-Jul-2021
Motoo Tanaka
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Motoo,
is there a solution for using no signed value, so I have the max resolution ?
Best regards
LuBe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear LuBe-san,
When I see the ADC Configuration, the value type for single-end seems to be always signed.
But for the Differential, we can choose signed or unsigned.
So if you set the input as differential and connect negative input to Vss,
you should be able to get unsigned value.
Please note that I have not tested this so please try and test before you proceed farther.
And last but not least, please consult with the ADC Component Datasheet, too 😉
Best Regards,
13-Jul-2021
Motoo Tanaka
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
yes I can but I need more pins for differential mode.
Best regards
LuBe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear LuBe-san,
We could gain the value by using Accumulate for Averaging mode,
but the resolution will be still the same.
Meantime, you may need to check if the value is negative and treat the negative values as 0.
That's about all I can think of right now.
Best Regards,
13-Jul-2013
Motoo Tanaka