Keil Logo

MON51: Sharing Serial Port with User Application


Information in this article applies to:

  • C51 All Versions
  • µVision Version 2.20a

QUESTION

I'm using MON51 and the µVision Debugger to download my program and debug it on my target system.

Can my program share the serial port with the monitor?

ANSWER

Yes. However, there are a few limitations that you should consider.

  1. Your target program must not change the serial port configuration in any way. This means that your application must not change the settings of any serial port SFRs or any baud rate timer SFRs. If your program does change these registers, the monitor will lose communications with the PC. You can easily do this using a #ifndef directive.

    #ifndef MONITOR
    SCON  = 0x50;      /* SCON: mode 1, 8-bit UART, enable rcvr      */
    TMOD |= 0x20;      /* TMOD: timer 1, mode 2, 8-bit reload        */
    TH1   = 221;       /* TH1:  reload value for 1200 baud @ 16MHz   */
    TR1   = 1;         /* TR1:  timer 1 run                          */
    TI    = 1;         /* TI:   set TI to send first char of UART    */
    #endif
    

    You may wish to create a new target in your project for debugging with the monitor. In this target configuration, you can define MONITOR (in the compiler settings for all compiled modules) and monitor-specific code will be generated.

  2. The µVision Debugger supports a monitor-specific option named Stop Program Execution with Serial Interrupt. This option must be disabled (not checked) if your program uses the serial port. If this option is enabled, the monitor enables the serial port's interrupt and prevents your target program from transmitting characters.
  3. Received data may contain XON and XOFF characters (because of the protocol with the PC). You must filter these characters from the input stream.

All information that you transmit out the serial port will be received and displayed in the serial window in µVision.

SEE ALSO


Last Reviewed: Thursday, February 25, 2021


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.