Shop OBEX P1 Docs P2 Docs Learn Events
Uart loopback test — Parallax Forums

Uart loopback test

TyreBiterTyreBiter Posts: 40
edited 2005-07-31 19:28 in General Discussion
confused.gif

I am trying to connect two javelin processors together using the Uart class. I thought that I might be able to test and develop a communication interface on one javelin by connecting the transmit to the receive pins with the appropriate resistors and signal diodes.

It appears not to work.

Am I expecting too much of the uart virtual peripheral system? Or is there possibly another problem?

confused.gif

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-07-31 19:28
    To test a serial protocol, just connect the tx pin, via a 1k resistor, to the rx pin.

    static final int rxpin = CPU.pin1;

    static final int txpin = CPU.pin0;



    static Uart txUart = new Uart(Uart.dirTransmit,txpin,Uart.dontInvert,Uart.speed1200,Uart.stop1);

    static Uart rxUart = new Uart(Uart.dirReceive,rxpin,Uart.dontInvert,Uart.speed1200,Uart.stop1);


    static void main() {
    int count = 25; char rxchar = 0; char txchar = 0;
    · while (true) {
    ··· if (rxUart.byteAvailable()) {
    ······rxchar = rxUart.receiveByte();·//receive
    ····· System.out.print(rxchar); //should be 'A' to 'Z' repeatedly
    ··· }
    ··· CPU.delay(10500); //wait 1 second
    ··· count = (count+1) % 26;
    ··· txchar = (char)(count+ 0x41); //send 'A' to 'Z' repeatedly
    ··· txUart.sendByte(txchar);
    · }
    }

    regards peter
Sign In or Register to comment.