ADC Interrupts in the LPC2214

Started by bmiller_rc May 13, 2005
We are trying to use the ADC interrupts in the LPC2214. We use the
following code and get a ready bit but no interrupt. Could someone
that has been through this drill take a look. We have generated
interrupts using the capture registers, but that is about it so
far. Thanks for the help.

-----------------
------------- asm -----------------------------------
-----------------
/* Setup the Timer1 interrupt service routine address into the
VIC controller... */
ldr r0, =VICAddr0RegAddr
ldr r1, =do_timer1
str r1, [r0]

/* Setup this channel as being valid (0x20), and configure for
the
timer 1 interrupt (0x5)... */
ldr r0, =VICCtrl0RegAddr
mov r1, #0x25
str r1, [r0]

/* Setup the ADC interrupt service routine address into the
ViController */
ldr r0, =VICAddr1RegAddr
ldr r1, =do_ADC1
str r1, [r0]

/* Setup this channel as being valide (0x20) and configure for
the ADC interrupt (0x12)
ldr r0, =VICCtrl1RegAddr
mov r1, #(0x20 + 0x12) /* 0x20-enable int, 0x12 -int to
handle */
str r1, [r0]

/* Remap vectors to RAM before enabling interrupts
*/
ldr r6,
=RMPCON

ldr r5,
=REMAP_2_RAM

str r5,
[r6]
/* Enable interrupts, enter supervisor mode and branch to start
of 'C' code */

msr cpsr_c, #0x13 /* I=0 F=0 T=0 MODE=supervisor
*/
bl
main /********************************************************************
*********
* Interrupt
exceptions *
*********************************************************************
*********/
do_timer1:
stmfd r13!, {r12, r14} /* save r12 & r14 */
mrs r12, spsr /* copy the spsr into r12 */
stmfd r13!, {r12} /* and save to the stack
*/
msr cpsr_c, #0x93 /* switch to Supervisor
mode */
stmfd r13!, {r0-r3, r14} /* save Supervisor mode
registers */
msr cpsr_c, #0x13 /* enable interrupts */
bl TimerInterrupt1 /* go handle the interrupt
*/
msr cpsr_c, #0x93 /* disable interrupts */
ldmfd r13!, {r0-r3, r14} /* restore Supervisor mode
registers */
msr cpsr_c, #0x92 /* switch back to irq mode
*/
ldmfd r13!, {r12} /* restore spsr */
msr spsr_cxsf, r12
ldmfd r13!, {r12, r14} /* restore r12 & r14 */
stmfd r13!, {r0-r1} /* save r0 & r1 */
ldr r0, =VICVecAddr /* update VIC */
mov r1, #0xff
str r1, [r0]
ldmfd r13!, {r0-r1} /* restore r0 & r1 */
subs pc, lr, #0x4 /* return from the
interrupt */ do_ADC1:
stmfd r13!, {r12, r14} /* save r12 & r14 */
mrs r12, spsr /* copy the spsr into r12 */
stmfd r13!, {r12} /* and save to the stack
*/
msr cpsr_c, #0x93 /* switch to Supervisor
mode */
stmfd r13!, {r0-r3, r14} /* save Supervisor mode
registers */
msr cpsr_c, #0x13 /* enable interrupts */
bl ADCInterrupt1 /* go handle the interrupt */
msr cpsr_c, #0x93 /* disable interrupts */
ldmfd r13!, {r0-r3, r14} /* restore Supervisor mode
registers */
msr cpsr_c, #0x92 /* switch back to irq mode
*/
ldmfd r13!, {r12} /* restore spsr */
msr spsr_cxsf, r12
ldmfd r13!, {r12, r14} /* restore r12 & r14 */
stmfd r13!, {r0-r1} /* save r0 & r1 */
ldr r0, =VICVecAddr /* update VIC */
mov r1, #0xff
str r1, [r0]
ldmfd r13!, {r0-r1} /* restore r0 & r1 */
subs pc, lr, #0x4 /* return from the
interrupt */

/********************************************************************
**********
* End of startup and interrupt
code *
*********************************************************************
*********/

------
----------C language setup----------------
------

#define INTERRUPT_5 0x00000020
#define INTERRUPT_18 0x00040000

void InitializeInterrupts()
{
/* Disable all interrupts to VIC */
REG( VICIntEnClear ) = 0xffffffff;
/* Set VIC to only handle IRQ and not FIQ */
REG( VICIntSelect ) = 0x00000000;

/* Now enable the desired interrupts */
/* Enable Timer1 and ADC interrupt to VIC */
REG( VICIntEnable ) = INTERRUPT_5| INTERRUPT_18;

}

//Setup the ADC
void AINSelect(void)
{
REG(ADCR) = 0x00200001;
REG(ADCR) |= 0x01000000;
iAIN = 8;
}



An Engineer's Guide to the LPC2100 Series