Help with interrupts please

Hello

I'm having a heck of a time trying to get interrupts to work on my MCU. All my coding is in C, and basically I want to jump to an isr whenever I sense something in my serial port. So I wrote a function like this:

interrupt 20 void isr(void) {....}

the function just spits out some characters to let me know it's ok. I found the number 20 in my data sheet listed as the "Vector Num"

so.... in my main() I have enabled interrupts and I have enabled the RDRF interrupt by setting the REI bit .... I figured that by doing that if something comes into my serial port, I would be sent to that other function.... but it's not working at all.....

I don't know if this is how the RDRF interrupt works, does anyone know what I'm doing wrong?

Thank you Joshua

PS - I'm using an HCS12 MCU and Codewarrior

Reply to
panfilero
Loading thread data ...

On 23 Mar 2007 19:37:30 -0700, "panfilero" wrote in comp.arch.embedded:

I'm not familiar with that particular part, but if that's all you're doing to get this particular interrupt to work, I can see why you're having a problem. Have you set a baud rate and enabled the serial port to receive?

If your purpose is to test your ability to work with your tool set and successfully write an ISR function in C, it might be easier to get one of the micro's timers working and get a timer ISR to work, that way you're not dependent on a data stream from an external source.

--
Jack Klein
Home: http://JK-Technology.Com
 Click to see the full signature
Reply to
Jack Klein

Hi

I have the serial port initialized and can transfer data to and from it. I just have a system that is running a program and whenever it recieves something on the serial port I need it to go and do something else. In my data sheet it says my Interupt Vector address for the serial port is $FFD6.... I think I'm suppose to put the address of my isr at the $FFD6 memory location. and then when I recieve something at the serial port I will go into my isr.... but I'm coding in C (not that I could do this in any other language) and I don't know how to put the address of my isr at $FFD6......

basically I don't know how to write an isr in C, I thought if I typed: Interrupt 20 void isr(void) it would do it, but it doesn't

thanks Joshua

Reply to
panfilero

Have you searched all the supplied examples, for the word interrupt ? It's not an unusual or rare thing you are trying, so they will probably have interrupts in some examples.

-jg

Reply to
Jim Granville

thanks guys, it ended up being this software called "serial monitor" thats loaded on my demo board wasn't letting me use interrupts on the serial port.

Reply to
panfilero

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.