This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Interrupt

This is probably pretty basic, but I can't figure out why it doesn't work.

I am working with a MSC1211Y5 evaluation board, and I am trying to
test the serial interrupts on the board. I feel like I've written
what I need to trigger an interrupt, but it doesn't enter into my
interrupt function (this is programmed in C). I'm still pretty new
to this (as you can see) and haven't found the resources to help me
with this. Shouldn't the following code trigger a serial interrupt?

void main ( void ) {

REN_0 = 1;
TB8_0 = 1;
SM0_0 = 1;
SM1_0 = 0;
TI_0 = 0;
TH1 = -3;
ES = 1;
EA = 1;

while (1) {
SBUF = 0x88;
} }

Basically, I feel that it should enter an interrupt whenever SBUF is
written to, right? Because the T1 flag should get set. My interrupt
is named like this:

void serial_isr (void) interrupt 1

I tested if the T1 flag gets set by doing:
while (1) {
SBUF = 0x88;
if (T1 == 1) serial_isr();
}

and it worked! (I removed the "interrupt 1" sign next to the second function). So I'm not sure what I didn't set.

Thanks in advance for any help.

Parents
  • You most certainly do not want to be fiddling directly with ACC in a 'C' program!

    Note that it is customary to reserve UPPERCASE names for #defines.

    "Whenever I type a key, it should echo it back, right? "

    rather unlikely I'm afraid - you're relying on the received character being in ACC after INCHAR returns, and still being in ACC by the time you've called OUTCHR.
    You might just possibly be lucky in this trivial case, but you certainly can not rely upon it in any general way at all!!

    You need to get a proper 'C' textbook, and study how to pass parameters to functions, and return values from functions.

Reply
  • You most certainly do not want to be fiddling directly with ACC in a 'C' program!

    Note that it is customary to reserve UPPERCASE names for #defines.

    "Whenever I type a key, it should echo it back, right? "

    rather unlikely I'm afraid - you're relying on the received character being in ACC after INCHAR returns, and still being in ACC by the time you've called OUTCHR.
    You might just possibly be lucky in this trivial case, but you certainly can not rely upon it in any general way at all!!

    You need to get a proper 'C' textbook, and study how to pass parameters to functions, and return values from functions.

Children