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

Using debugger with real serial port

Has anybody had trouble getting the simulator to use a real serial port instead of the builtin serial terminal?

Here is my configuration thats loaded on debug:
MODE COM1 19200, 0, 8, 1
ASSIGN WIN <NUL >NUL
ASSIGN COM1 <SIN >SOUT

My simulated program can output serial data through the PC serial port all day long without problems, however when my application reads a byte the simulation hangs.

My code runs fine on the real hardware, and it runs fine in the simulator using the builtin serial terminal window, it only hangs when reading a byte, with the assignment to COM1:

Ive tested my cables, so i know thats not an issue here. Ive tried the above conf with out assigning NUL to WIN as well, no luck.

Any thoughs or suggestions would be greatly appreciated.

Parents
  • Does it transmit OK to COM1: ?

    When the simulated 8051 program writes a byte to it's serial port, the byte does get written and moved through the PCs serial port. What doesnt work is when the 8051 tries to get a byte from the serial port. It hangs.

    If you dont mind me asking, how are you handling serial data in your 8051 applications? Are you using interrupts? Right now i'm polling for my reads, using the following function:

    unsigned char get_byte(void){
    	for(;;){
    		if(RI==1){
    			RI=0;
    			return SBUF;
    		}
    	}
    }
    

    And this function has worked well on the simulator using the builtin serial window, and on the real hardware.

    Ive tried every thing i can think of except for trying this using interrupts for serial. I'll give that a shot and post the result.

Reply
  • Does it transmit OK to COM1: ?

    When the simulated 8051 program writes a byte to it's serial port, the byte does get written and moved through the PCs serial port. What doesnt work is when the 8051 tries to get a byte from the serial port. It hangs.

    If you dont mind me asking, how are you handling serial data in your 8051 applications? Are you using interrupts? Right now i'm polling for my reads, using the following function:

    unsigned char get_byte(void){
    	for(;;){
    		if(RI==1){
    			RI=0;
    			return SBUF;
    		}
    	}
    }
    

    And this function has worked well on the simulator using the builtin serial window, and on the real hardware.

    Ive tried every thing i can think of except for trying this using interrupts for serial. I'll give that a shot and post the result.

Children
  • "If you dont mind me asking, how are you handling serial data in your 8051 applications? Are you using interrupts?"

    I would generally use interrupts.

    Long shot: is it a genuine COM port, or a USB-to-Serial adaptor? (not that it should make any difference!)

  • "Right now i'm polling for my reads, using the following function"

    With polled input, your code will "hang" if it doesn't get any input - that would be correct operation!

    Are you sure that your COM port and cables are all working and correctly wired?

    Have you tried just using hypoterminal (or whatever) on that COM: port?
    Does it receive OK?

    What is the source of the data you're expecting to receive?

  • With polled input, your code will "hang" if it doesn't get any input - that would be correct operation!

    Yep, it hangs, thats what i want it to do. The problem is, it still hangs even when i send it a byte from over the serial port to the program running in the simulator.

    Here is whats going on:
    The simulated program can send bytes through the PCs serial port.

    The simulated program when waiting for a byte never gets it even though i am clearly sending a byte to it.

    So the simulated program can send bytes through the PCs serial port, but it cannot read bytes.

    The same code can send and receive using the builtin serial terminal.

    The same code can send a receive bytes on real hardware connected to external devices.

    So what i am trying to determine here is if there is a quirk in the simulator? Do i need to use interrupt driven routines for serial to be correctly handled in the simulator through the PC's serial port? I would think the simulator would handle a polled serial routine properly as well as an interrupt driven one, what are yall doing in this regard?

  • Are you sure that your COM port and cables are all working and correctly wired?

    Have you tried just using hypoterminal (or whatever) on that COM: port?
    Does it receive OK?


    I am fairly certain that my serial connection is good. I have an rs232 analyzer ( specifically http://www.fte.com/sta01.asp ) I'm also using a breakout box as well. I have minicom on a macintosh, and hyperterm on the PC, i have verified that serial data with my cables works in both directions.

    Ive tested the program in the simulated 8052 with mincom on the other machine, to make sure there werent any errors with the other device i am interfacing to.