LPC55xx ADC interrupt routine

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC55xx ADC interrupt routine

2,629 Views
ianbenton
Senior Contributor I

Would I be correct in thinking that the interrupt routine should clear STAT[TCOMP_INT] ?

Without doing so the interrupt routine runs continuously. I don't see any statement to that effect in the manual.

5 Replies

89 Views
danielholala
Senior Contributor II

Hello,

That was helpful, even 5 years later.

I'm using multiple ADC channels on the LPC55xx. The ADC FIFO is read out when the ADC interrupt fires. I'm using the FIFO watermark interrupt (FWMIE0). Regarding interrupt status bits, I do not have to reset any flags in the ADC status register as they (e.g., RDY0) apparently get reset automatically as soon as the FIFO has been read out completely.

Today I changed the code from FWMIE0 to Trigger completion interrupt ("TCOMP_IE") and my ISR ran continously, as you observed. So to fix this, after reading out FIFO, I have to clear  TCOMP_INT bit in the ADC status register by writing a 1 to this bit:

ADC0->STAT &= 1U << ADC_STAT_TCOMP_INT_SHIFT;

I wish NXP would put more effort, time and people to work on the documentation. I'm glad we have this community here.

Thanks
Daniel

 

0 Kudos
Reply

2,613 Views
frank_m
Senior Contributor III

I would suppose any set interrupt flag would cause a continuous interrupt execution. The only difference is, certain flags like result ready get reset automatically on reading the result register.

I use to start out with an interrupt handler that clears all enabled interrupt flags regardless of their status.

0 Kudos
Reply

2,618 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello,

STAT[TCOMP_INT] is for trigger interrupt flag, not ADC result ready interrupt flag.

If you want to use ADC trigger interrupt, yes, you need write 1 to clear it.

About read ADC data interrupt function, please refer to ADC interrupt demo under  SDK.

Strongly recommend you debug and run the ADC demo first.

 

Thanks.

 

BR

Alice

0 Kudos
Reply

2,606 Views
ianbenton
Senior Contributor I

When the SDK creates a project, it creates over 60,000 lines of code. I have searched for ADC0_IRQHandler in most of the logical places it could possibly be, but can't find it.

0 Kudos
Reply

2,595 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello,

For example lpadc_interrupt demo:

Alice_Yang_0-1639371812110.png

 

BR

Alice

 

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-1383493%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ELPC55xx%20ADC%20interrupt%20routine%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1383493%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EWould%20I%20be%20correct%20in%20thinking%20that%20the%20interrupt%20routine%20should%20clear%20STAT%5BTCOMP_INT%5D%20%3F%3C%2FP%3E%3CP%3EWithout%20doing%20so%20the%20interrupt%20routine%20runs%20continuously.%20I%20don't%20see%20any%20statement%20to%20that%20effect%20in%20the%20manual.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2294537%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20LPC55xx%20ADC%20interrupt%20routine%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2294537%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3EThat%20was%20helpful%2C%20even%205%20years%20later.%3C%2FP%3E%3CP%3EI'm%20using%20multiple%20ADC%20channels%20on%20the%20LPC55xx.%20The%20ADC%20FIFO%20is%20read%20out%20when%20the%20ADC%20interrupt%20fires.%20I'm%26nbsp%3Busing%20the%20%3CSTRONG%3EFIFO%20watermark%20interrupt%3C%2FSTRONG%3E%20(FWMIE0).%20Regarding%20interrupt%20status%20bits%2C%20I%20do%20not%20have%20to%20reset%20any%20flags%20in%20the%20ADC%20status%20register%20as%20they%20(e.g.%2C%20RDY0)%20apparently%20get%20reset%20automatically%20as%20soon%20as%20the%20FIFO%20has%20been%20read%20out%20completely.%3C%2FP%3E%3CP%3EToday%20I%20changed%20the%20code%20from%26nbsp%3BFWMIE0%20to%26nbsp%3B%3CSTRONG%3ETrigger%20completion%20interrupt%3C%2FSTRONG%3E%20(%22TCOMP_IE%22)%20and%20my%20ISR%20ran%20continously%2C%20as%20you%20observed.%20So%20to%20fix%20this%2C%20after%20reading%20out%20FIFO%2C%20I%20have%20to%20clear%26nbsp%3B%20TCOMP_INT%20bit%20in%20the%20ADC%20status%20register%20by%20writing%20a%201%20to%20this%20bit%3A%3C%2FP%3E%3CDIV%3E%3CP%3E%3CFONT%20face%3D%22andale%20mono%2Ctimes%22%3E%3CSPAN%3EADC0-%26gt%3B%3C%2FSPAN%3E%3CSPAN%3ESTAT%3C%2FSPAN%3E%3CSPAN%3E%20%26amp%3B%3D%201U%20%26lt%3B%26lt%3B%20ADC_STAT_TCOMP_INT_SHIFT%3B%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FP%3E%3CP%3EI%20wish%20NXP%20would%20put%20more%20effort%2C%20time%20and%20people%20to%20work%20on%20the%20documentation.%20I'm%20glad%20we%20have%20this%20community%20here.%3C%2FP%3E%3CP%3EThanks%3CBR%20%2F%3EDaniel%3C%2FP%3E%3CBR%20%2F%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1385342%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20LPC55xx%20ADC%20interrupt%20routine%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1385342%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%2C%3C%2FP%3E%0A%3CP%3EFor%20example%20lpadc_interrupt%20demo%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Alice_Yang_0-1639371812110.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Alice_Yang_0-1639371812110.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F164895i5AB9DF49AC916EFC%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Alice_Yang_0-1639371812110.png%22%20alt%3D%22Alice_Yang_0-1639371812110.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EBR%3C%2FP%3E%0A%3CP%3EAlice%3C%2FP%3E%0A%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1384226%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20LPC55xx%20ADC%20interrupt%20routine%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1384226%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EWhen%20the%20SDK%20creates%20a%20project%2C%20it%20creates%20over%2060%2C000%20lines%20of%20code.%20I%20have%20searched%20for%26nbsp%3BADC0_IRQHandler%20in%20most%20of%20the%20logical%20places%20it%20could%20possibly%20be%2C%20but%20can't%20find%20it.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1383990%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20LPC55xx%20ADC%20interrupt%20routine%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1383990%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI%20would%20suppose%20any%20set%20interrupt%20flag%20would%20cause%20a%20continuous%20interrupt%20execution.%20The%20only%20difference%20is%2C%20certain%20flags%20like%20result%20ready%20get%20reset%20automatically%20on%20reading%20the%20result%20register.%3C%2FP%3E%3CP%3EI%20use%20to%20start%20out%20with%20an%20interrupt%20handler%20that%20clears%20all%20enabled%20interrupt%20flags%20regardless%20of%20their%20status.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1383928%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20LPC55xx%20ADC%20interrupt%20routine%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1383928%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%2C%3C%2FP%3E%0A%3CP%3ESTAT%5BTCOMP_INT%5D%20is%20for%20trigger%20interrupt%20flag%2C%20not%20ADC%20result%20ready%20interrupt%20flag.%3C%2FP%3E%0A%3CP%3EIf%20you%20want%20to%20use%20ADC%20trigger%20interrupt%2C%20yes%2C%20you%20need%20write%201%20to%20clear%20it.%3C%2FP%3E%0A%3CP%3EAbout%20read%20ADC%20data%20interrupt%20function%2C%20please%20refer%20to%20ADC%20interrupt%20demo%20under%26nbsp%3B%20SDK.%3C%2FP%3E%0A%3CP%3EStrongly%20recommend%20you%20debug%20and%20run%20the%20ADC%20demo%20first.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EThanks.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EBR%3C%2FP%3E%0A%3CP%3EAlice%3C%2FP%3E%3C%2FLINGO-BODY%3E