Shop OBEX P1 Docs P2 Docs Learn Events
CPU.installVP() & CPU.removeVP() Not Working — Parallax Forums

CPU.installVP() & CPU.removeVP() Not Working

newnapmannewnapman Posts: 4
edited 2005-08-16 22:56 in General Discussion
I have a UART object that reads in serial data. After it is declared in code (and automatically installed), it ALWAYS works.

If I place a removeVP() & installVP() (As showen in the "Javelin Stamp Hardware Refernce" P. 165) before using the object, then the UART no longer works. HELP.

Working Code:
...
static Uart Uart_rx = new Uart( Uart.dirReceive,  CPU.pin3, Uart.dontInvert, Uart.speed9600, Uart.stop1 );
...
public static void main() {
  ...
  if ( Uart_rx.byteAvailable() ) {
    System.out.println(Uart_rx.receiveByte());
  }
  ...
}
...




NOT Working Code (There is never a byte available):
...
static Uart Uart_rx = new Uart( Uart.dirReceive,  CPU.pin3, Uart.dontInvert, Uart.speed9600, Uart.stop1 );
...
public static void main() {
  ...
  CPU.removeVP(Uart_rx);
  CPU.installVP(Uart_rx);
  ...
  if ( Uart_rx.byteAvailable() ) {
    System.out.println(Uart_rx.receiveByte());
  }
  ...
}
...




Please help... What is wrong?

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-08-16 22:56
    Use Uart_rx.stop() to stop the uart (and remove vp),

    use Uart_rx.start() to start the Uart (and install vp).

    The start() method initializes all necessary Uart registers.

    regards peter
Sign In or Register to comment.