EmbeddedRelated.com
Forums
Memfault Beyond the Launch

hc12 IRQ interrupt - help please

Started by cristian_d27 November 14, 2002
For several days I've been trying to use the irq interrupt (low
voltage on port e pin 1) without any success. I'm using metrowerks
code warrior and a dbug12 board. How could I set the hc12 so that it
executes my service routine when that pin goes low?. I have tried
many methods (setting my service routine trought the prm file, using
#pragma directives and setting the vector table)but none has ended in
success, any help hint or example could be useful thanks.



In a message dated 11/14/02 6:37:29 PM Eastern Standard Time,
writes:

> How could I set the hc12 so that it
> executes my service routine when that pin goes low?.

In general, interrupts need to be enabled (execute a cli), the irq vector in
rom needs to point to the handler, possibly thru a jmp instruction, and the
handler needs to clear the irq by writing something to somewhere so that when
the handler does an rti, it doesnt interrupt right back into the handler.



Thanks for your reply Bob, Still I have trouble setting up the vector
table (pointing to the handler, Im using SetUserVector() of the
Dbug12), does anyone knows a way to do that with or without the
SetUserVector() in codewarrior.

--- In 68HC12@y..., BobGardner@a... wrote:
> In a message dated 11/14/02 6:37:29 PM Eastern Standard Time,
> cristian_d27@y... writes:
>
> > How could I set the hc12 so that it
> > executes my service routine when that pin goes low?.
>
> In general, interrupts need to be enabled (execute a cli), the irq
vector in
> rom needs to point to the handler, possibly thru a jmp instruction,
and the
> handler needs to clear the irq by writing something to somewhere so
that when
> the handler does an rti, it doesnt interrupt right back into the
handler.




In a message dated 11/14/02 7:53:30 PM Eastern Standard Time,
writes:

> Thanks for your reply Bob, Still I have trouble setting up the vector
> table (pointing to the handler, Im using SetUserVector() of the
> Dbug12), does anyone knows a way to do that with or without the
> SetUserVector() in codewarrior.

I use ICC.... dont know about dbug or codewarrior, but if there is an
'examine memory' function, look at the tail end of rom and note where the irq
vector is pointing... probably to a jump table in the top of ram... the
operand address of the jmp needs to get filled in with the address of the
handler....


What version of D-Bug12 are you using? The reference manual for v3 & v4
detail the location of the RAM based vector table used by D-Bug12. Each one
of the RAM vectors is two bytes, so all you have to do is have Codewarrior
generate a two byte constant of the address of the interrupt vector & have
it loaded into the proper location in the RAM vector table.

Regards,
Gordon

cristian_d27 wrote:

> Thanks for your reply Bob, Still I have trouble setting up the vector
> table (pointing to the handler, Im using SetUserVector() of the
> Dbug12), does anyone knows a way to do that with or without the
> SetUserVector() in codewarrior.
>
> --- In 68HC12@y..., BobGardner@a... wrote:
> > In a message dated 11/14/02 6:37:29 PM Eastern Standard Time,
> > cristian_d27@y... writes:
> >
> > > How could I set the hc12 so that it
> > > executes my service routine when that pin goes low?.
> >
> > In general, interrupts need to be enabled (execute a cli), the irq
> vector in
> > rom needs to point to the handler, possibly thru a jmp instruction,
> and the
> > handler needs to clear the irq by writing something to somewhere so
> that when
> > the handler does an rti, it doesnt interrupt right back into the
> handler.
> >
> >
> > -------------------- >
> ">http://docs.yahoo.com/info/terms/




Using Metrowerks, I handle the IRQ on my board as follows:

#define nIRQ 6

void interrupt nIRQ nIRQHandler(void)
{
// interrupt code here
}

This form automatically initializes the vector table for you.

If you have the IRQ set as level sensitive, you need external hardware to
hold the line low until the ISR releases it. If you are edge triggered, the
IRQ is latched and cleared automatically.

Don't forget to enable interrupts using: asm("cli");

Regards,

Paul Johnson

> -----Original Message-----
> From: cristian_d27 [mailto:]
> Sent: Thursday, November 14, 2002 3:35 PM
> To:
> Subject: [68HC12] hc12 IRQ interrupt - help please > For several days I've been trying to use the irq interrupt (low
> voltage on port e pin 1) without any success. I'm using metrowerks
> code warrior and a dbug12 board. How could I set the hc12 so that it
> executes my service routine when that pin goes low?. I have tried
> many methods (setting my service routine trought the prm file, using
> #pragma directives and setting the vector table)but none has ended in
> success, any help hint or example could be useful thanks. >
> -------------------- >
> ">http://docs.yahoo.com/info/terms/ >





Memfault Beyond the Launch