Reply by Ernst Cozijnsen February 12, 20092009-02-12
@Jan: I've got a lpc2148

>Is the timer interrupt on vector 1? If it is 4 you

>need to call:

>ctl_set_isr( 4, 0, CTL_ISR_TRIGGER_ FIXED, isr, 0);

>ctl_unmask_isr( 4);

Setting the timer interrupt to 4 worked. I misread the manual thinking this was the interrupt number

>Is the init_isr() called? In main you call only

>init().

Ehmmm yes that was indeed a beginners mistake

@ Paul:

>> T0IR = 0x01; //clear interrupt

>> VICVectAddr = 0; //end of interrupt - dummy write

>You don't need to do the write, our library does this for you.

I i remove the lines the interrupt hangs so ehmmm does it need a substitution?

But...... its working now so i'm almost there ;-)

--- On Thu, 2/12/09, Paul Curtis wrote:

From: Paul Curtis
Subject: RE: [lpc2000] Setting up interrupts in crossworks problem?
To: l...
Date: Thursday, February 12, 2009, 7:32 PM


Hi,

> int main(void)

> {

> init();

> PINSEL1 = 0x10000000; //p0.30 = AD0.3

> IODIR0 = 0x00200000; //p0.21 = output

> AD0CR = 0x00210e08; //start burst A/D on AD0.3

> T0TCR = 0x02; //reset counter

> T0IR = 0xff;

> T0MCR = 0x0003; //interrupt and reset on MR0

> T0MR0 = 0x00124f80; //compare-hit count

> // VICVectCntl0 = 0x00000024; //use it for Timer 0 Interrupt:

> // VICVectAddr0 = (unsigned)isr; //set interrupt vector in 0

> // VICIntEnable = 0x00000010; //enable TIMER0 interrupt

> T0TCR = 0x01; //enable Timer0

> ctl_global_interrup ts_enable( );

>

> while(1){

> }

> }

>

> void isr(void)

> {

> // let burn some LED's

> T0IR = 0x01; //clear interrupt

> VICVectAddr = 0; //end of interrupt - dummy write

You don't need to do the write, our library does this for you.

> void init_isr(void)

> {

> ctl_set_isr( 1, 0, CTL_ISR_TRIGGER_ FIXED, isr, 0);

> ctl_unmask_isr( 1);

> }

Are you sure vector #1 is correct? Try looking it up.

--

Paul Curtis, Rowley Associates Ltd http://www.rowley. co.uk

CrossWorks for ARM, MSP430, AVR, MAXQ, and now Cortex-M3 processors






















An Engineer's Guide to the LPC2100 Series

Reply by Paul Curtis February 12, 20092009-02-12
Hi,

> int main(void)
> {
> init();
> PINSEL1 = 0x10000000; //p0.30 = AD0.3
> IODIR0 = 0x00200000; //p0.21 = output
> AD0CR = 0x00210e08; //start burst A/D on AD0.3
> T0TCR = 0x02; //reset counter
> T0IR = 0xff;
> T0MCR = 0x0003; //interrupt and reset on MR0
> T0MR0 = 0x00124f80; //compare-hit count
> // VICVectCntl0 = 0x00000024; //use it for Timer 0 Interrupt:
> // VICVectAddr0 = (unsigned)isr; //set interrupt vector in 0
> // VICIntEnable = 0x00000010; //enable TIMER0 interrupt
> T0TCR = 0x01; //enable Timer0
> ctl_global_interrupts_enable();
>
> while(1){
> }
> }
>
> void isr(void)
> {
> // let burn some LED's
> T0IR = 0x01; //clear interrupt
> VICVectAddr = 0; //end of interrupt - dummy write

You don't need to do the write, our library does this for you.

> void init_isr(void)
> {
> ctl_set_isr(1, 0, CTL_ISR_TRIGGER_FIXED, isr, 0);
> ctl_unmask_isr( 1);
> }

Are you sure vector #1 is correct? Try looking it up.

--
Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
CrossWorks for ARM, MSP430, AVR, MAXQ, and now Cortex-M3 processors

Reply by Jan Vanek February 12, 20092009-02-12
Hi Ernst,

what processor?

Is the timer interrupt on vector 1? If it is 4 you
need to call:
ctl_set_isr(4, 0, CTL_ISR_TRIGGER_FIXED, isr, 0);
ctl_unmask_isr( 4);

Is the init_isr() called? In main you call only
init().

You can try to set a breakpoint in the isr() or do
some output on debug
terminal, like:
debug_printf("here\n");
You need to
#include "cross_studio_io.h"
for it.

With regards,
Jan
----- Original Message -----
From: "Ernst Cozijnsen"
To:
Sent: Thursday, February 12, 2009 7:55 PM
Subject: RE: [lpc2000] Setting up interrupts in
crossworks problem?
Ok thanks guys i'm a little further but not yet there.
If i look in the examples from the both of you and
Rowley's this is how it
should look i think.
Only downside..... its not working
Reading the manual part of ctl_api this should be
working.

In the startup file i've also enabled:
VECTORED_IRQ_INTERRUPTS

What could this be?

#include
#define PLOCK 0x400
void init(void);
void delay_ms(int);

volatile int servo;

int main(void)
{
init();
PINSEL1 = 0x10000000; //p0.30 = AD0.3
IODIR0 = 0x00200000; //p0.21 = output
AD0CR = 0x00210e08; //start burst A/D on AD0.3
T0TCR = 0x02; //reset counter
T0IR = 0xff;
T0MCR = 0x0003; //interrupt and reset on MR0
T0MR0 = 0x00124f80; //compare-hit count
// VICVectCntl0 = 0x00000024; //use it for Timer 0
Interrupt:
// VICVectAddr0 = (unsigned)isr; //set interrupt
vector in 0
// VICIntEnable = 0x00000010; //enable TIMER0
interrupt
T0TCR = 0x01; //enable Timer0
ctl_global_interrupts_enable();

while(1){
}
}

void isr(void)
{
// let burn some LED's
T0IR = 0x01; //clear interrupt
VICVectAddr = 0; //end of interrupt - dummy write
}

void init_isr(void)
{
ctl_set_isr(1, 0, CTL_ISR_TRIGGER_FIXED, isr, 0);
ctl_unmask_isr( 1);
}
Gr,

Ernst
--- On Wed, 2/11/09, Martijn Broens
wrote:

From: Martijn Broens
Subject: RE: [lpc2000] Setting up interrupts in
crossworks problem?
To: l...
Date: Wednesday, February 11, 2009, 8:11 PM

Hi Ernst,

Have a look at the example code provided by Rowley. It
should give you som

insight.

Here's an example of how I've set it up.

void External_ISR( void){

int Port0Val = 0;

switch(IOIntStatus) {

case IOIntStatus_ P0Int: // Audio detect

Port0Val = FIO0PIN;

OnAudioDetect_ ISR(Port0Val) ;

IO0IntClr = AUDIO_DETECT_ 1|AUDIO_DETECT_
2|AUDIO_DETECT_ 3; // clear

Interrupt flag

break;

case IOIntStatus_ P2Int: // Headset detect

onHeadsetDetect_ ISR();

IO2IntClr = HEADSET_DETECT; // clear Interrupt flag

break;

default:

IO0IntClr = 1;

IO2IntClr = 1;

break;

}

EXTINT= EXTINT_EINT3;

}

#define EINT3_INT 17

void Init_ExternalISR( void){

bit_clear(EXTMODE, EXTMODE_EXTMODE3) ; /* EXT3
is level sensitive */

bit_set(EXTPOLAR, EXTPOLAR_EXTPOLAR3) ; /* EXT3
is rising edge

sensitive */

bit_set(PINSEL4, 26); /* Configure for alternate
function EINT3 */

bit_clear(PINSEL4, 27);

// setup pins 0.23, 0.24, 0.25 falling isr and clear
pending isr.

IO0IntEnR |= AUDIO_DETECT_ 1|AUDIO_DETECT_
2|AUDIO_DETECT_ 3;

IO0IntClr |= AUDIO_DETECT_ 1|AUDIO_DETECT_
2|AUDIO_DETECT_ 3;

// setup headset isr

DEBUGP("Enabling headset detect ISR...\n");

IO2IntEnR |= HEADSET_DETECT;

IO2IntClr |= HEADSET_DETECT;

// install isr

ctl_set_isr( EINT3_INT, 1, CTL_ISR_TRIGGER_ FIXED,
External_ISR, 0);

ctl_unmask_isr( EINT3_INT) ;

DEBUGP("Audio detect inputs enabled \n");

}

In this code I check for external isr's on port 0 and
port 2 of an lpc2468

and when an isr comes I check the cause, and act on
it.

Hope this helps

thanks martijn

_____

From: lpc2000@yahoogroups .com
[mailto:lpc2000@yahoogroups .com] On Behalf
Of

Jan Vanek

Sent: woensdag 11 februari 2009 20:52

To: lpc2000@yahoogroups .com

Subject: Re: [lpc2000] Setting up interrupts in
crossworks problem?

Hi Ernst,

you need to declare or define the isr() function

before you can pass it's

address to the ctl_set_isr( ..., isr, ...).

void isr(void);

ctl_global_interrup ts_enable( );

ctl_set_isr( 1, 0, CTL_ISR_TRIGGER_ FIXED, isr, 0);

ctl_unmask_isr( 1);

Regards,

Jan

----- Original Message -----

From: "ernst.cozijnsen"
yahoo.com>

To: 40yahoogroups. com> .com>

Sent: Wednesday, February 11, 2009 8:06 PM

Subject: [lpc2000] Setting up interrupts in crossworks

problem?

Hello People,

I'm having a little setting up interrupts in

crossworks.

Reading the manual I found that i need to use:

ctl_global_interrup ts_enable( );

ctl_set_isr( 1, 0, CTL_ISR_TRIGGER_ FIXED, isr, 0);

ctl_unmask_isr( 1);

To setup the interrupt instead of using:

void isr (void) __attribute_ _ ((interrupt( "IRQ")));

&

// VICVectCntl0 = 0x00000024; //use it for

Timer 0 Interrupt:

// VICVectAddr0 = (unsigned)isr; //set

interrupt vector in 0

// VICIntEnable = 0x00000010; //enable

TIMER0 interrupt

If i try this crossworks starts giving errors like:

"'isr' undeclared (first use in this function) "

A shove in the correct dir would be appreciated

Ernst





Reply by Ernst Cozijnsen February 12, 20092009-02-12
Ok thanks guys i'm a little further but not yet there.
If i look in the examples from the both of you and Rowley's this is how it should look i think.
Only downside..... its not working
Reading the manual part of ctl_api this should be working.

In the startup file i've also enabled: VECTORED_IRQ_INTERRUPTS

What could this be?

#include
#define PLOCK 0x400
void init(void);
void delay_ms(int);

volatile int servo;

int main(void)
{
init();
PINSEL1 = 0x10000000; //p0.30 = AD0.3
IODIR0 = 0x00200000; //p0.21 = output
AD0CR = 0x00210e08; //start burst A/D on AD0.3
T0TCR = 0x02; //reset counter
T0IR = 0xff;
T0MCR = 0x0003; //interrupt and reset on MR0
T0MR0 = 0x00124f80; //compare-hit count
// VICVectCntl0 = 0x00000024; //use it for Timer 0 Interrupt:
// VICVectAddr0 = (unsigned)isr; //set interrupt vector in 0
// VICIntEnable = 0x00000010; //enable TIMER0 interrupt
T0TCR = 0x01; //enable Timer0
ctl_global_interrupts_enable();

while(1){
}
}

void isr(void)
{
// let burn some LED's
T0IR = 0x01; //clear interrupt
VICVectAddr = 0; //end of interrupt - dummy write
}

void init_isr(void)
{
ctl_set_isr(1, 0, CTL_ISR_TRIGGER_FIXED, isr, 0);
ctl_unmask_isr( 1);
}
Gr,

Ernst
--- On Wed, 2/11/09, Martijn Broens wrote:

From: Martijn Broens
Subject: RE: [lpc2000] Setting up interrupts in crossworks problem?
To: l...
Date: Wednesday, February 11, 2009, 8:11 PM


Hi Ernst,

Have a look at the example code provided by Rowley. It should give you som

insight.

Here's an example of how I've set it up.

void External_ISR( void){

int Port0Val = 0;

switch(IOIntStatus) {

case IOIntStatus_ P0Int: // Audio detect

Port0Val = FIO0PIN;

OnAudioDetect_ ISR(Port0Val) ;

IO0IntClr = AUDIO_DETECT_ 1|AUDIO_DETECT_ 2|AUDIO_DETECT_ 3; // clear

Interrupt flag

break;

case IOIntStatus_ P2Int: // Headset detect

onHeadsetDetect_ ISR();

IO2IntClr = HEADSET_DETECT; // clear Interrupt flag

break;

default:

IO0IntClr = 1;

IO2IntClr = 1;

break;

}

EXTINT= EXTINT_EINT3;

}

#define EINT3_INT 17

void Init_ExternalISR( void){

bit_clear(EXTMODE, EXTMODE_EXTMODE3) ; /* EXT3 is level sensitive */

bit_set(EXTPOLAR, EXTPOLAR_EXTPOLAR3) ; /* EXT3 is rising edge

sensitive */

bit_set(PINSEL4, 26); /* Configure for alternate function EINT3 */

bit_clear(PINSEL4, 27);

// setup pins 0.23, 0.24, 0.25 falling isr and clear pending isr.

IO0IntEnR |= AUDIO_DETECT_ 1|AUDIO_DETECT_ 2|AUDIO_DETECT_ 3;

IO0IntClr |= AUDIO_DETECT_ 1|AUDIO_DETECT_ 2|AUDIO_DETECT_ 3;

// setup headset isr

DEBUGP("Enabling headset detect ISR...\n");

IO2IntEnR |= HEADSET_DETECT;

IO2IntClr |= HEADSET_DETECT;

// install isr

ctl_set_isr( EINT3_INT, 1, CTL_ISR_TRIGGER_ FIXED, External_ISR, 0);

ctl_unmask_isr( EINT3_INT) ;

DEBUGP("Audio detect inputs enabled \n");

}

In this code I check for external isr's on port 0 and port 2 of an lpc2468

and when an isr comes I check the cause, and act on it.

Hope this helps

thanks martijn

_____

From: lpc2000@yahoogroups .com [mailto:lpc2000@yahoogroups .com] On Behalf Of

Jan Vanek

Sent: woensdag 11 februari 2009 20:52

To: lpc2000@yahoogroups .com

Subject: Re: [lpc2000] Setting up interrupts in crossworks problem?

Hi Ernst,

you need to declare or define the isr() function

before you can pass it's

address to the ctl_set_isr( ..., isr, ...).

void isr(void);

ctl_global_interrup ts_enable( );

ctl_set_isr( 1, 0, CTL_ISR_TRIGGER_ FIXED, isr, 0);

ctl_unmask_isr( 1);

Regards,

Jan

----- Original Message -----

From: "ernst.cozijnsen"
yahoo.com>

To: .com>

Sent: Wednesday, February 11, 2009 8:06 PM

Subject: [lpc2000] Setting up interrupts in crossworks

problem?

Hello People,

I'm having a little setting up interrupts in

crossworks.

Reading the manual I found that i need to use:

ctl_global_interrup ts_enable( );

ctl_set_isr( 1, 0, CTL_ISR_TRIGGER_ FIXED, isr, 0);

ctl_unmask_isr( 1);

To setup the interrupt instead of using:

void isr (void) __attribute_ _ ((interrupt( "IRQ")));

&

// VICVectCntl0 = 0x00000024; //use it for

Timer 0 Interrupt:

// VICVectAddr0 = (unsigned)isr; //set

interrupt vector in 0

// VICIntEnable = 0x00000010; //enable

TIMER0 interrupt

If i try this crossworks starts giving errors like:

"'isr' undeclared (first use in this function) "

A shove in the correct dir would be appreciated

Ernst
























Reply by Martijn Broens February 11, 20092009-02-11
Hi Ernst,

Have a look at the example code provided by Rowley. It should give you som
insight.

Here's an example of how I've set it up.

void External_ISR(void){

int Port0Val = 0;

switch(IOIntStatus){

case IOIntStatus_P0Int: // Audio detect

Port0Val = FIO0PIN;

OnAudioDetect_ISR(Port0Val);

IO0IntClr = AUDIO_DETECT_1|AUDIO_DETECT_2|AUDIO_DETECT_3; // clear
Interrupt flag

break;

case IOIntStatus_P2Int: // Headset detect

onHeadsetDetect_ISR();

IO2IntClr = HEADSET_DETECT; // clear Interrupt flag

break;

default:

IO0IntClr = 1;

IO2IntClr = 1;

break;

}

EXTINT= EXTINT_EINT3;

}

#define EINT3_INT 17

void Init_ExternalISR(void){

bit_clear(EXTMODE, EXTMODE_EXTMODE3); /* EXT3 is level sensitive */

bit_set(EXTPOLAR, EXTPOLAR_EXTPOLAR3); /* EXT3 is rising edge
sensitive */

bit_set(PINSEL4, 26); /* Configure for alternate function EINT3 */

bit_clear(PINSEL4, 27);

// setup pins 0.23, 0.24, 0.25 falling isr and clear pending isr.

IO0IntEnR |= AUDIO_DETECT_1|AUDIO_DETECT_2|AUDIO_DETECT_3;

IO0IntClr |= AUDIO_DETECT_1|AUDIO_DETECT_2|AUDIO_DETECT_3;

// setup headset isr

DEBUGP("Enabling headset detect ISR...\n");

IO2IntEnR |= HEADSET_DETECT;

IO2IntClr |= HEADSET_DETECT;

// install isr

ctl_set_isr(EINT3_INT, 1, CTL_ISR_TRIGGER_FIXED, External_ISR, 0);

ctl_unmask_isr(EINT3_INT);

DEBUGP("Audio detect inputs enabled \n");

}

In this code I check for external isr's on port 0 and port 2 of an lpc2468
and when an isr comes I check the cause, and act on it.

Hope this helps

thanks martijn

_____

From: l... [mailto:l...] On Behalf Of
Jan Vanek
Sent: woensdag 11 februari 2009 20:52
To: l...
Subject: Re: [lpc2000] Setting up interrupts in crossworks problem?

Hi Ernst,

you need to declare or define the isr() function
before you can pass it's
address to the ctl_set_isr(..., isr, ...).

void isr(void);

ctl_global_interrupts_enable();
ctl_set_isr(1, 0, CTL_ISR_TRIGGER_FIXED, isr, 0);
ctl_unmask_isr(1);

Regards,
Jan

----- Original Message -----
From: "ernst.cozijnsen" yahoo.com>
To: .com>
Sent: Wednesday, February 11, 2009 8:06 PM
Subject: [lpc2000] Setting up interrupts in crossworks
problem?

Hello People,

I'm having a little setting up interrupts in
crossworks.
Reading the manual I found that i need to use:

ctl_global_interrupts_enable();
ctl_set_isr(1, 0, CTL_ISR_TRIGGER_FIXED, isr, 0);
ctl_unmask_isr(1);

To setup the interrupt instead of using:

void isr (void) __attribute__ ((interrupt("IRQ")));

&

// VICVectCntl0 = 0x00000024; //use it for
Timer 0 Interrupt:
// VICVectAddr0 = (unsigned)isr; //set
interrupt vector in 0
// VICIntEnable = 0x00000010; //enable
TIMER0 interrupt

If i try this crossworks starts giving errors like:

"'isr' undeclared (first use in this function) "

A shove in the correct dir would be appreciated

Ernst



Reply by Jan Vanek February 11, 20092009-02-11
Hi Ernst,

you need to declare or define the isr() function
before you can pass it's
address to the ctl_set_isr(..., isr, ...).

void isr(void);

ctl_global_interrupts_enable();
ctl_set_isr(1, 0, CTL_ISR_TRIGGER_FIXED, isr, 0);
ctl_unmask_isr(1);

Regards,
Jan
----- Original Message -----
From: "ernst.cozijnsen"
To:
Sent: Wednesday, February 11, 2009 8:06 PM
Subject: [lpc2000] Setting up interrupts in crossworks
problem?
Hello People,

I'm having a little setting up interrupts in
crossworks.
Reading the manual I found that i need to use:

ctl_global_interrupts_enable();
ctl_set_isr(1, 0, CTL_ISR_TRIGGER_FIXED, isr, 0);
ctl_unmask_isr(1);

To setup the interrupt instead of using:

void isr (void) __attribute__ ((interrupt("IRQ")));

&

// VICVectCntl0 = 0x00000024; //use it for
Timer 0 Interrupt:
// VICVectAddr0 = (unsigned)isr; //set
interrupt vector in 0
// VICIntEnable = 0x00000010; //enable
TIMER0 interrupt

If i try this crossworks starts giving errors like:

"'isr' undeclared (first use in this function) "

A shove in the correct dir would be appreciated

Ernst

Reply by "ernst.cozijnsen" February 11, 20092009-02-11
Hello People,

I'm having a little setting up interrupts in crossworks.
Reading the manual I found that i need to use:

ctl_global_interrupts_enable();
ctl_set_isr(1, 0, CTL_ISR_TRIGGER_FIXED, isr, 0);
ctl_unmask_isr(1);

To setup the interrupt instead of using:

void isr (void) __attribute__ ((interrupt("IRQ")));

&

// VICVectCntl0 = 0x00000024; //use it for Timer 0 Interrupt:
// VICVectAddr0 = (unsigned)isr; //set interrupt vector in 0
// VICIntEnable = 0x00000010; //enable TIMER0 interrupt

If i try this crossworks starts giving errors like:

"'isr' undeclared (first use in this function) "

A shove in the correct dir would be appreciated

Ernst