Hallo

Nun weis ich auch, warum meine empfangenen Zeichen nur Schrott waren. Eine serielle Maus sendet ihre Daten in Paketen, einfache Protokolle sehen dafür drei Bytes vor:

Code:
Data packet is 3 byte packet. It is send to the computer every time mouse state changes (mouse moves or keys are pressed/released). 
        D7      D6      D5      D4      D3      D2      D1      D0
 
1.      X       1       LB      RB      Y7      Y6      X7      X6
2.      X       0       X5      X4      X3      X2      X1      X0      
3.      X       0       Y5      Y4      Y3      Y2      Y1      Y0

Note: The bit marked with X is 0 if the mouse received with 7 databits and 2 stop bits format. It is also possible to use 8 databits and 1 stop bit format for receiving. In this case X gets value 1. The safest thing to get everything working is to use 7 databits and 1 stopbit when receiving mouse information (and if you are making mouse then send out 7 databits and 2 stop bits). 
The byte marked with 1. is send first, then the others. The bit D6 in the first byte is used for syncronizing the software to mouse packets if it goes out of sync. 

LB is the state of the left button (1 means pressed down)
RB is the state of the right button (1 means pressed down)
X7-X0 movement in X direction since last packet (signed byte)
Y7-Y0 movement in Y direction since last packet (signed byte)

Graphical description how the data is contained in the packet
              1st byte        2nd byte         3rd byte
          ================  ===============  ================
           - 1 ? ? Y Y X X  - 0 X X X X X X  - 0 Y Y Y Y Y Y
          ================  ===============  ================
               | | \ / \ /      \---------/      \---------/
               | |  |   |            |                |
               | |  |   \----\       |                |
               | |  \--------|-------|--------\       |
               | |          / \ /---------\  / \ /---------\
               | |         ================ =================
               | |          0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0
 Left Button --/ |         ================ =================
Right Button ----/            X increment      Y increment

Mouse identification
When DTR line is toggled, mouse should send one data byte containing letter 'M' (ascii 77).
(gefunden bei: http://users.tkk.fi/~then/mytexts/mouse.html)

Das "M" zur Identifikation der Maus kann man im Terminalprogramm schön erkennen, die Datenbytes dann schon eher nicht (manche sollen ja auch Graycode "lesen" können).

Mein einfaches Testprogramm sieht nun so aus:
Code:
#include "../inc/asuro.h"

#define FOSC 8000000// Clock Speed
#define BAUD 1200
#define MYUBRR FOSC/16/BAUD-1

void USART_Init( unsigned int ubrr)
{
/* Set baud rate */
UBRRH = (unsigned char)(ubrr>>8);
UBRRL = (unsigned char)ubrr;
/* Enable receiver and transmitter */
UCSRB = (1<<RXEN)|(1<<TXEN);
/* Set frame format: 8data, 2stop bit */
/*UCSRC = (1<<URSEL)|(1<<USBS)|(3<<UCSZ0);*/
UCSRC = 0x8A; //10001010 = 7bit, 2stop, kein parity
}

int main( void )
{
char data;

Init();
USART_Init ( MYUBRR );
StatusLED(RED);
data=' ';

/*  Aufbau der Datenbits (Startbyte mit gesetztem D6!)
        D7      D6      D5      D4      D3      D2      D1      D0

1.      X       1       LB      RB      Y7      Y6      X7      X6
2.      X       0       X5      X4      X3      X2      X1      X0
3.      X       0       Y5      Y4      Y3      Y2      Y1      Y0

Quelle: http://users.tkk.fi/~then/mytexts/mouse.html
*/

while(1) {

SerRead(&data,1,0);
	if (data & 0x50) BackLED(OFF,ON);
	if (data & 0x60) BackLED(ON,OFF);
	if (data & 1) StatusLED(YELLOW); else StatusLED(RED);
SerWrite(&data,1);
}
return 0;
}
Die Maustasten steuern nun die BackLEDs, Bit 0 der Daten weiterhin die StatusLED. Der SerWrite-Befehl dient nur zur Kontrolle ob sich was tut. Man könnte auch z.B. den Inhalt der Bytes 2+3 senden.

Gruß

mic