# Sending/receiving serial from 6.270 board

When IC runs, the 6.270 board's serial port is set for 9600 baud, no parity, 1 stop bit. Normally the serial port is used for communication between the pcode on the board and IC running on the host. However, if you disconnect the board from IC on the host, it is possible for a program on the board to take over the serial port.

### Transmittings Characters

Transmitting characters is pretty easy; you basically just poke directly to the 6811's UART hardware. Here's how:

    void serial_putchar(int c)
    {
       while (!(peek(0x102e) & 0x80));  /* wait until serial transmit empty */
       poke(0x102f, c);  /* send character */
    }

Remember to stop IC (or disconnect the board) before you send characters out, since any characters you send will most likely confuse IC quite a bit.

Also, if you connect the board to a terminal emulator or other program/device which might send characters to the board, be sure to disable the pcode's handling of incoming serial (described in the next section). Otherwise, as soon as you send a character to the board, the board will wedge waiting for the rest of the packet (in the format IC would send). (One sign this is happening is that the heartbeat stops.)

### Receiving Characters

Receiving characters is only slightly more hard. You first have to tell the pcode running on the board to not pick up the characters itself. Note that this will disable downloading and other interaction if you hook back up to IC. This means you have to either reset the board or re-enable the pcode serial to get IC to interact with the board.

Here's the code:

    void disable_pcode_serial()   /* necessary to receive characters using serial_getchar */
    {
       poke(0x3c, 1);
    }

    void reenable_pcode_serial()   /* necessary for IC to interact with board again */
    {
       poke(0x3c, 0);
    }

    int serial_getchar(int c)
    {
       while (!(peek(0x102e) & 0x20)); /* wait for received character */
       return peek(0x102f);
    }