Veetsin mõnegi õhtu, et saada toimivat, minu kontrolli all olevat, USI SPI clock ja data signaali. Nüüd on esimene pääsuke olemas.
Selle tõestuseks, kollane on clock ja sinine minu test data (10000010
)
23
24 #include
25
26
27 void main(void)
28 {
29 WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
30 P1OUT = 0;
31 P1DIR |= 0x03;
32 USICTL0 |= USIPE7 + USIPE6 + USIPE5 + USIMST + USIOE; // Port, SPI master
33 USICTL1 |= USIIE; // Counter interrupt, flag remains set
34 USICKCTL = USIDIV_2 + USISSEL_2; // /4 SMCLK
35 P1OUT |= BIT6; // set cs
36 USICTL0 &= ~USISWRST; // USI released for operation
37 USICNT = 8; // init-load counter
38 _BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/ interrupt
39 }
40
41 // USI interrupt service routine
42 //#pragma vector=USI_VECTOR
43 //__interrupt void universal_serial_interface(void)
44 void universal_serial_interface(void) __attribute__((interrupt(USI_VECTOR)));
45 void universal_serial_interface(void) {
46 USISRL = 0b10000010; // test output data
47 USICNT = 8; // re-load counter
48 }