Moin, hier stehe ich schon wieder mit einem Problem:
1 | void spi_init(void) |
2 | {
|
3 | WDTCTL = WDTPW + WDTHOLD; // Stop WDT |
4 | //Verwende UCB0, da UCA0 von serieller Kommunkation belegt, UCB0 kann kein UART
|
5 | /* Disable USCI */
|
6 | UCB0CTL1 |= UCSWRST; |
7 | |
8 | /*
|
9 | * Control Register 0
|
10 | *
|
11 | * ~UCCKPH -- Data is changed on the first UCLK edge and captured on the following edge
|
12 | * UCCKPL -- Inactive state is high
|
13 | * UCMSB -- MSB first
|
14 | * ~UC7BIT -- 8-bit
|
15 | * UCMST -- Master mode
|
16 | * UCMODE_0 -- 3-Pin SPI
|
17 | * UCSYNC -- Synchronous Mode
|
18 | *
|
19 | * Note: ~<BIT> indicates that <BIT> has value zero
|
20 | */
|
21 | UCB0CTL0 = UCCKPH + UCMSB + UCMST + UCMODE_0 + UCSYNC; //mode(0,0) |
22 | |
23 | /*
|
24 | * Control Register 1
|
25 | *
|
26 | * UCSSEL_2 -- SMCLK
|
27 | * UCSWRST -- Enabled. USCI logic held in reset state
|
28 | */
|
29 | UCB0CTL1 = UCSSEL_2 + UCSWRST; |
30 | |
31 | /* Bit Rate Control Register 0 */
|
32 | UCB0BR0 = 2; |
33 | |
34 | /* Enable USCI */
|
35 | UCB0CTL1 &= ~UCSWRST; |
36 | //_EINT(); // Enable interrupts
|
37 | }
|
38 | |
39 | |
40 | void spi_send_char(char c) // ein einzelnes zeichen über die serielle schnittstelle (USART1) senden |
41 | {
|
42 | while (!(IFG2 & UCB0TXIFG)); // warten, bis USART1 TX-buffer sendebereit |
43 | UCB0TXBUF = c; |
44 | |
45 | |
46 | }
|
Wenn ich nicht vollkommen zu blöd bin mein Oszilloskop abzulesen (nicht ganz ausgeschlossen), sendet dieser Code-Schnippsel einen übergebenen char mit dem LSB zuerst, also rückwärts. Wieso tut er das? Gruß Hannes