Created
December 22, 2019 08:35
-
-
Save kendhia/f6158a8af55835d99ebec2d82d4e386e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <msp430.h> | |
int main(void) | |
{ | |
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer | |
// If clock sig from mstr stays low, it is not yet in SPI mode | |
while (!(P1IN & BIT4)); | |
P1SEL = BIT1 + BIT2 + BIT4; | |
P1SEL2 = BIT1 + BIT2 + BIT4; | |
UCA0CTL1 = UCSWRST; // **Put state machine in reset** | |
UCA0CTL0 |= UCCKPL + UCMSB + UCSYNC; // 3-pin, 8-bit SPI master | |
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine** | |
IE2 |= UCA0RXIE; // Enable USCI0 RX interrupt | |
__bis_SR_register(LPM4_bits + GIE); // Enter LPM4, enable interrupts | |
} | |
// Slave RX ISR | |
#pragma vector=USCIAB0RX_VECTOR | |
__interrupt void USCI0RX_ISR (void) | |
{ | |
while (!(IFG2 & UCA0TXIFG)); // USCI_A0 TX buffer ready? | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment