ADC SAR interrupt

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
LuBe_4654241
Level 4
Level 4
50 sign-ins 25 replies posted 25 sign-ins

Hi,

in my project I'd like to add interrupt in ADC SAR, but I receive the following error:

LuBe_4654241_0-1626159006946.png

Why ?

Best regards

LuBe

0 Likes
1 Solution
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

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

 

View solution in original post

0 Likes
7 Replies
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

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

 

0 Likes

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

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

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

 

0 Likes

Hi Motoo,

is there a solution for using no signed value, so I have the max resolution ?

Best regards

LuBe

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

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.

001-Config-1.JPG

So if you set the input as differential and connect negative input to Vss,

you should be able to get unsigned value.

002-Config-2.JPG

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

0 Likes

Hi,

yes I can but I need more pins for differential mode.

Best regards

LuBe

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

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.

003-Config-3.JPG

That's about all I can think of right now.

Best Regards,

13-Jul-2013

Motoo Tanaka

0 Likes