Hi, ich suche nach einer Möglichkeit um mit dem MSP430F2013 über SPI daten an ein Arduino Uno zu senden. Leider habe ich es noch nicht hin bekommen. MSP430F2013 Beispiel Code: SPI full-Duplex 3-wire Master
1 | *******************************************************************************
|
2 | *
|
3 | * MSP430 CODE EXAMPLE DISCLAIMER |
4 | *
|
5 | * MSP430 code examples are self-contained low-level programs that typically |
6 | * demonstrate a single peripheral function or device feature in a highly |
7 | * concise manner. For this the code may rely on the device's power-on default |
8 | * register values and settings such as the clock configuration and care must |
9 | * be taken when combining code from several examples to avoid potential side |
10 | * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware |
11 | * for an API functional library-approach to peripheral configuration. |
12 | *
|
13 | * --/COPYRIGHT--*/ |
14 | //******************************************************************************
|
15 | // MSP430F20x2/3 Demo - SPI full-Duplex 3-wire Master
|
16 | //
|
17 | // Description: SPI Master communicates full-duplex with SPI Slave using
|
18 | // 3-wire mode. The level on P1.4 is TX'ed and RX'ed to P1.0.
|
19 | // Master will pulse slave reset for synch start.
|
20 | // ACLK = n/a, MCLK = SMCLK = Default DCO
|
21 | //
|
22 | // Slave Master
|
23 | // MSP430F20x2/3 MSP430F20x2/3
|
24 | // ----------------- -----------------
|
25 | // | XIN|- /|\| XIN|-
|
26 | // | | | | |
|
27 | // | XOUT|- --|RST XOUT|-
|
28 | // | | /|\ | |
|
29 | // | RST/NMI|--+<----|P1.2 |
|
30 | // LED <-|P1.0 | | P1.4|<-
|
31 | // ->|P1.4 | | P1.0|-> LED
|
32 | // | SDI/P1.7|<-------|P1.6/SDO |
|
33 | // | SDO/P1.6|------->|P1.7/SDI |
|
34 | // | SCLK/P1.5|<-------|P1.5/SCLK |
|
35 | //
|
36 | // M. Buccini / L. Westlund
|
37 | // Texas Instruments Inc.
|
38 | // October 2005
|
39 | // Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.40A
|
40 | //******************************************************************************
|
41 | |
42 | #include <msp430.h> |
43 | |
44 | int main(void) |
45 | {
|
46 | volatile unsigned int i; |
47 | |
48 | WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer |
49 | P1OUT = 0x10; // P1.4 set, else reset |
50 | P1REN |= 0x10; // P1.4 pullup |
51 | P1DIR = 0x01; // P1.0 output, else input |
52 | USICTL0 |= USIPE7 + USIPE6 + USIPE5 + USIMST + USIOE; // Port, SPI master |
53 | USICTL1 |= USIIE; // Counter interrupt, flag remains set |
54 | USICKCTL = USIDIV_4 + USISSEL_2; // /16 SMCLK |
55 | USICTL0 &= ~USISWRST; // USI released for operation |
56 | USISRL = P1IN; // init-load data |
57 | |
58 | P1DIR |= 0x04; // Reset Slave |
59 | P1DIR &= ~0x04; |
60 | for (i = 0xFFF; i > 0; i--); // Time for slave to ready |
61 | USICNT = 8; // init-load counter |
62 | __bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupt |
63 | }
|
64 | |
65 | // USI interrupt service routine
|
66 | #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
|
67 | #pragma vector=USI_VECTOR
|
68 | __interrupt void universal_serial_interface(void) |
69 | #elif defined(__GNUC__)
|
70 | void __attribute__ ((interrupt(USI_VECTOR))) universal_serial_interface (void) |
71 | #else
|
72 | #error Compiler not supported!
|
73 | #endif
|
74 | {
|
75 | if (0x10 & USISRL) |
76 | P1OUT |= 0x01; |
77 | else
|
78 | P1OUT &= ~0x01; |
79 | USISRL = P1IN; |
80 | USICNT = 8; // re-load counter |
81 | }
|
SPI full-Duplex 3-wire Slave
1 | //******************************************************************************
|
2 | // MSP430F20x2/3 Demo - SPI full-Duplex 3-wire Slave
|
3 | //
|
4 | // Description: SPI Master communicates full-duplex with SPI Slave using
|
5 | // 3-wire mode. The level on P1.4 is TX'ed and RX'ed to P1.0.
|
6 | // Master will pulse slave reset for synch start.
|
7 | // ACLK = n/a, MCLK = SMCLK = Default DCO
|
8 | //
|
9 | // Slave Master
|
10 | // MSP430F20x2/3 MSP430F20x2/3
|
11 | // ----------------- -----------------
|
12 | // | XIN|- /|\| XIN|-
|
13 | // | | | | |
|
14 | // | XOUT|- --|RST XOUT|-
|
15 | // | | /|\ | |
|
16 | // | RST/NMI|--+<----|P1.2 |
|
17 | // LED <-|P1.0 | | P1.4|<-
|
18 | // ->|P1.4 | | P1.0|-> LED
|
19 | // | SDI/P1.7|<-------|P1.6/SDO |
|
20 | // | SDO/P1.6|------->|P1.7/SDI |
|
21 | // | SCLK/P1.5|<-------|P1.5/SCLK |
|
22 | //
|
23 | // M. Buccini / L. Westlund
|
24 | // Texas Instruments Inc.
|
25 | // October 2005
|
26 | // Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.40A
|
27 | //******************************************************************************
|
28 | |
29 | #include <msp430.h> |
30 | |
31 | int main(void) |
32 | {
|
33 | WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer |
34 | P1OUT = 0x10; // P1.4 set, else reset |
35 | P1REN |= 0x10; // P1.4 pullup |
36 | P1DIR = 0x01; // P1.0 output, else input |
37 | USICTL0 |= USIPE7 + USIPE6 + USIPE5 + USIOE; // Port, SPI slave |
38 | USICTL1 |= USIIE; // Counter interrupt, flag remains set |
39 | USICTL0 &= ~USISWRST; // USI released for operation |
40 | USISRL = P1IN; // init-load data |
41 | USICNT = 8; // init-load counter |
42 | |
43 | __bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupt |
44 | }
|
45 | |
46 | // USI interrupt service routine
|
47 | #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
|
48 | #pragma vector=USI_VECTOR
|
49 | __interrupt void universal_serial_interface(void) |
50 | #elif defined(__GNUC__)
|
51 | void __attribute__ ((interrupt(USI_VECTOR))) universal_serial_interface (void) |
52 | #else
|
53 | #error Compiler not supported!
|
54 | #endif
|
55 | {
|
56 | if (0x10 & USISRL) |
57 | P1OUT |= 0x01; |
58 | else
|
59 | P1OUT &= ~0x01; |
60 | USISRL = P1IN; |
61 | USICNT = 8; // re-load counter |
62 | }
|
Bei Arduino weis ich nicht wie ich nun die MSP430F2013 werte auslesen/schreiben kann.