UART: Only receiving mess on RasberryPi when connected to a PIC18
I connected the TX pin of the PIC to a GPIO input pin of my RaspberryPi and wrote a little program to monitor what's going on:

    #include &lt;assert.h&gt;
    #include &lt;fcntl.h&gt;
    #include &lt;stdint.h&gt;
    #include &lt;stdio.h&gt;
    #include &lt;sys/mman.h&gt;
    #include &lt;sys/stat.h&gt;
    #include &lt;sys/time.h&gt;
    #include &lt;time.h&gt;
    #include &lt;unistd.h&gt;

    #define BLOCK_SIZE 256

    #define GPIO_IN(g)  *(gpio+((g)/10)) &amp;= ~(7&lt;&lt;(((g)%10)*3))
    #define GPIO_OUT(g) *(gpio+((g)/10)) |=  (1&lt;&lt;(((g)%10)*3))

    #define GPIO_SET(g)  *(gpio+7)  = 1&lt;&lt;(g)
    #define GPIO_CLR(g)  *(gpio+10) = 1&lt;&lt;(g)
    #define GPIO_LEV(g) (*(gpio+13) &gt;&gt; (g)) &amp; 0x1

    #define PIN 18

    int                mem_fd;
    void              *gpio_map;
    volatile uint32_t *gpio;

    unsigned long ellapsed(struct timespec last, struct timespec now)
    {
      unsigned long diff = now.tv_sec - last.tv_sec;
      diff *= 1e9;
      diff += now.tv_nsec - last.tv_nsec;
      return diff;
    }

    int main()
    {
      mem_fd = open("/dev/gpiomem", O_RDWR|O_SYNC);
      assert(mem_fd != -1);

      gpio_map = mmap(NULL, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, mem_fd, 0);
      assert(gpio_map != MAP_FAILED);
      gpio = (volatile uint32_t*)gpio_map;

      GPIO_IN(PIN);

      struct timespec last, now;
      clock_gettime(CLOCK_BOOTTIME, &amp;last);
      char state = 1;
      while (1)
        {
          if ((state &amp; 0x1) != (GPIO_LEV(PIN)))
            {
              clock_gettime(CLOCK_BOOTTIME, &amp;now);
              printf("state changed from %d to %d after %f µsecs (= %f kHz)\n", state, GPIO_LEV(PIN), ellapsed(last, now)/1000.0, 1.0/(ellapsed(last,now)/1e9)/1e3);
              last = now;
              state = GPIO_LEV(PIN);
            }
        }
    }


The speed was about 207 µsec per bit. I looked up the speed of uart and found that this equals a baud rate of 4800, exactly half of what I expected. Dividing n through 2 gives me the correct baud rate, although I don't understand why this is needed, as neither the datasheet nor the internet tells about such behaviour.