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

Serial Data lost

I wrote an aplication that receives data from the serial interface (80251)
When running under the uvision dscope debugger I go into the serial peripheral window and enter the data into SBUF. Then I set the interrupt. My input data is displayed in the serial window, and the interrupt triggers my ISR. The only problem is that the SBUF data never gets copied into my global variable of my program.
In C ,I have the statement rcv_data = SBUF

In assembly I get MOV A,SBUF(0x99)
MOV rcv_data(0x12F),R11
The instruction to move the SBUF (loc 0x99) to the Accumulater gets ignorred
Since memory location 0x99(SBUF) does not get pulled into the accumulater, the data never gets into my variable.
I set breakpoints all over this area and I can't understand why the instruction doesn't seem to move the data over. I can write to the accumulator with no problem in the command window (ie. A=0x49). (setting a break at this address within the interrupt.
Does anyone know what could cause this...

  • In assembly I get:

    MOV A,SBUF(0x99)
    MOV rcv_data(0x12F),R11


    The instruction to move the SBUF (loc 0x99) to the Accumulater gets ignorred...


    In the 251, the Accumulator IS R11.

    Jon

  • Jon,
    Thanks for the reply.
    I'm a little surprised that the compiler uses the A and R11 symbols, and not just R11, but the fact remains that I can see my data get into the SBUF (address 0x99) but never gets written to the accumulator (symbol A in the assembly code; and it is set to 0), so it's no surprise that when R11 gets moved in my variable it is set to 0.
    Just as an aside, maybe this means something, after I load my code into d-scope I have to inline assemble an ejmp serialIntr? into the vector table because a plain jmp is used.
    Thanks in advance for your suggestions.

    jim

  • I go into the serial peripheral window and enter the data into SBUF. Then I set the interrupt.

    I guess I missed this before. This WILL NOT WORK.

    Why don't you just type your data into the serial window and let the debugger generate the interrupt automatically?

    Or, use the SIN VTREG as follows:

    SIN = 'A'
    from the Command window.

    The debugger will generate the interrupt automatically.

    Remember that when you WRITE to SBUF, you are writing a character that will be sent. When you READ from SBUF, you read a character that has been received.

    The on-chip UART sets TI when a character has been transmitter and RI when a character has been received.

    If you "trick" the processor by generating an interrupt when no character has been received, you will not receive a valid character.

    Jon

  • Thanks, Jon
    Problem solved. I was really pulling my hair out on that one.
    Now I can get into testing the stuff I churned out.

    Thanks again!!!!!!1
    Jim