Ich möchte gerne Startbit + 2 Byte Nutzdaten + 1 Byte CRC8 + Stopbit
über Port 1.1 senden und über Port 1.2 empfangen können.
Zunächst soll es nur mal darum gehen zu senden, denn da fängt schon mein
Problem an.
Als Grundgerüst habe ich den im Anhang beigefügten Code benutzt, der für
die Kommunikation mit RS232 für einzelne Zeichen auch ausgezeichnet
funktioniert.
Rufe ich jetzt in o.g. modifizierten Code die Transmit-Funktion mit
identischen Testmustern 3x hintereinander auf:
1 | //Hauptprogramm
|
2 | TXByte = 0xAA;
|
3 | Transmit(0);
|
4 | TXByte = 0xAA;
|
5 | Transmit(1);
|
6 | TXByte = 0xAA;
|
7 | Transmit(2);
|
8 |
|
9 | //Transmit
|
10 | void Transmit(unsigned char zaehler)
|
11 | {
|
12 | while(isReceiving); // Wait for RX completion
|
13 | TACCTL0 = OUT; // Timer A Capture/Compare Control Register
|
14 | // Output high
|
15 | TACTL = TASSEL_2 + MC_2; // Timer A Control Register
|
16 | // TASSEL: Timer_A clock source select _2 = 0b10 -> SMCLK
|
17 | // MC: Mode control _2 -> continuous mode
|
18 | // zählt bis 0xFFFF = 65535
|
19 |
|
20 | if (zaehler == 0) BitCnt = 0x9; // 8 bits + Startbit
|
21 | if (zaehler == 1) BitCnt = 0x8; // 8 bits
|
22 | if (zaehler == 2) BitCnt = 0x9; // 8 bits + Stopbit
|
23 |
|
24 | TACCR0 = TAR; // Initialize compare register mit Inhalt Timer A Register
|
25 |
|
26 | TACCR0 += Bitzeit; // Set time till first bit
|
27 |
|
28 | if (zaehler == 0) TXByte = TXByte << 1; // Startbit
|
29 | if (zaehler == 2) TXByte |= 0x100; // Stopbit
|
30 |
|
31 | TACCTL0 = CCIS0 + OUTMOD0 + CCIE; // Timer A Capture/Compare Control Register
|
32 | // CCIS: Capture/compare input select. -> 0 = CCIxA
|
33 | // OUTMOD: Output mode -> 0 = OUT bit value
|
34 | // CCIE: Capture/compare interrupt enable -> 1 = Interrupt enabled
|
35 | // Set signal, intial value, enable interrupts
|
36 |
|
37 | while ( TACCTL0 & CCIE ); // Wait for previous TX completion
|
38 | }
|
erhalte ich die im Anhang beigefügte Übetragung. Ihr erkennt deutlich
die Pause von ca. 2 Bit zwischen den Bytes.
Meine Frage ist jetzt, wie ich die Pause da herausbekomme?