LPC55xx A/D interrupt

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

LPC55xx A/D interrupt

665 Views
ianbenton
Senior Contributor I

I am using a LPC5502 with the A/D converter being triggered by the CTIMER0, which should sample 1600 times a second. The A/D triggers an interrupt when the scan is complete.

However, my interrupt routine appears to run continuously (running once every 50us).

Is there a flag that needs to be cleared? Is it cleared by writing a zero or by writing a 1?

6 Replies

635 Views
ianbenton
Senior Contributor I

Write HALF the cycle time to MR3 and MST3

Set bits 10 and 27 in MCR to make it reset and reload.

Set bits 10 and 11 of EMR to make it toggle on match (that’s why you need half the cycle time)

Set bit 0 of TCR to make it go.

 

then set bits 0 and 24 in TCTRL5 in the A/D to make it trigger from input 5 and run command 1.

if you need an interrupt when it has finished, set bit 21 of IE

 

in the A/D, set bits 0 and 24 of TCTRL5 to enable the trigger from input 5 and run CMD0 ( or whatever command you want it to run)

if you want an interrupt when it has completed the conversion, set bit 21 of IE.

 

0 Kudos

629 Views
danielholala
Senior Contributor II

Dear @ianbenton ,

Thanks for confirming that configuring external match register (EMR) to toggle the output bit (EMR[EMC3] = 0x3) will effectively double the cycle time. That's exactly how I configured the timer. I was unsure about this as it has been recommended to set the output bit instead. But then you need to reset the bit somewhere (e.g., ISR) manually.

Further, I noticed that the FIFO overflows while single stepping during debugging. This also created perpetual irqs (as I had enabled fifo overflow interrupt but not yet handled it in my code).

I think I'm getting there

 

0 Kudos

648 Views
danielholala
Senior Contributor II

I don't know what happened (I don't remember having touched anything regarding ADC/CTIMER configuration), but now I observe the same behavior that you reported. The ADC ISR is called permanently with a much higher frequency than the CTIMER trigger.

How did you resolve this issue?

Cheers,
Dan

0 Kudos

642 Views
ianbenton
Senior Contributor I

This won’t help you at all, but I corrected the gormless mistake that I made in calculating the cycle length!

0 Kudos

638 Views
danielholala
Senior Contributor II

You are right. 

And I should make sure to read out the FIFO completely in ADC ISR.

0 Kudos

652 Views
danielholala
Senior Contributor II

Hi @ianbenton ,

I have the same application in mind but I'm struggling to get CTIMER to trigger ADC. If I understand the user manual correctly, ADC conversion can be triggered by CTIMER directly. With "directly" I mean, that the trigger mechanism is done in hardware and not implemented in software (by writing a timer ISR that writes to ADC register SWTRIG to generate a software trigger). Could you please provide your configuration?

For your information, I have CTIMER configured as follows using Peripheral Tools, see screenshot below:

 

danielholala_3-1670844707366.png

 

Note: I start the timer manually in my code. The timer is running as I can see that the TC register is running.

Do I have to select an "output control" and do I have to route the output to an actual pin? I assume that "Toggle bit" means that the actual trigger rate is reduced by factor two as the "hardware trigger events are detected on the rising-edge of the associated hardware trigger source." (according to the manual).

Thank you.

Best regards,
Daniel

0 Kudos