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
  • Hey, didn't want to start a new thread, but I'm having some problems! I'm trying to read from the serial port, and it just gives me gibberish, so I wrote out a program from a textbook I have, it goes like this:

    #include <reg51.h>
    #include <stdio.h>

    sbit AccMSB = ACC^7;

    void OUTCHR (void)
    { CY = P;
    CY = !CY;
    AccMSB = CY;
    while (TI != 1);
    TI = 0;
    SBUF = ACC;
    AccMSB = 0;
    }

    void INCHAR (void)
    { while (RI != 1);
    RI = 0;
    ACC = SBUF;
    CY = P;
    CY = !CY;
    AccMSB = 0;
    }

    main ()
    { SCON = 0x52;
    TMOD = 0x20;
    TH1 = -13;
    TR1 = 1;

    while (1)
    { INCHAR();
    OUTCHR();
    } }

    Whenever I type a key, it should echo it back, right? Well, all it gives me are strange characters; unfortunately, I can't copy it from the Terminal Window, its not letting me (I'm using the Terminal window in the TI downloader).

    I know its kind of hard without the output, but has this happened to anyone else?

    Actually, I just went through Word, and was able to find the Unicode representations:

    0 - two characters, 8+ 00FE (latin small letter thorn)
    1 - 00C6 (latin capital AE)
    2 - same as 0
    3 - same as 1
    4 - > (yes, the greater than symbol)
    5 - two characters, 00FE+00FE (latin small letter thorn)
    6 - same as 4
    7 - same as 5
    8 - same as 0
    9 - same as 1

    Thanks in advance for any help or advice

Reply
  • Hey, didn't want to start a new thread, but I'm having some problems! I'm trying to read from the serial port, and it just gives me gibberish, so I wrote out a program from a textbook I have, it goes like this:

    #include <reg51.h>
    #include <stdio.h>

    sbit AccMSB = ACC^7;

    void OUTCHR (void)
    { CY = P;
    CY = !CY;
    AccMSB = CY;
    while (TI != 1);
    TI = 0;
    SBUF = ACC;
    AccMSB = 0;
    }

    void INCHAR (void)
    { while (RI != 1);
    RI = 0;
    ACC = SBUF;
    CY = P;
    CY = !CY;
    AccMSB = 0;
    }

    main ()
    { SCON = 0x52;
    TMOD = 0x20;
    TH1 = -13;
    TR1 = 1;

    while (1)
    { INCHAR();
    OUTCHR();
    } }

    Whenever I type a key, it should echo it back, right? Well, all it gives me are strange characters; unfortunately, I can't copy it from the Terminal Window, its not letting me (I'm using the Terminal window in the TI downloader).

    I know its kind of hard without the output, but has this happened to anyone else?

    Actually, I just went through Word, and was able to find the Unicode representations:

    0 - two characters, 8+ 00FE (latin small letter thorn)
    1 - 00C6 (latin capital AE)
    2 - same as 0
    3 - same as 1
    4 - > (yes, the greater than symbol)
    5 - two characters, 00FE+00FE (latin small letter thorn)
    6 - same as 4
    7 - same as 5
    8 - same as 0
    9 - same as 1

    Thanks in advance for any help or advice

Children