ARM Technical Support Knowledge Articles

HOW TO CONNECT TWO PORT PINS

Applies to: uVision Debugger

Answer


Information in this article applies to:


QUESTION

I need to simulate a connection between two port pins. Is this possible to do in the uVision simulator?

ANSWER

Yes. You must create a signal function that copies the output port pin to the input port pin. In general, the steps to do this are:

  1. Use the wwatch function to wait for the Output PORTx VTReg to get written.
  2. Read the pin value from the Output PORTx VTReg.
  3. Write the pin value to the Input PORTx VTReg.

The following example connects the Output Pin (PORT1.7) to the Input Pin (PORT2.1). The application must configure P1.7 as an output and P2.1 as an input:

/* define port_loopback function */
signal void port_loopback (void) {
  printf("loopback signal function is started
");
  while (1) {
    wwatch (PORT1);         /* wait for PORT1 (VTR) access      */
    if (PORT1 & 0x80) {     /* set PORT2.1 depending on PORT1.7 */
      PORT2 |= 0x02;
    } else {
      PORT2 &= ~0x02;
    }
  }
}

/* start port_loopback function */
port_loopback()

SEE ALSO

Article last edited on: 2005-10-12 05:57:08

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential