Blame | Last modification | View Log | Download | RSS feed
#include <msp430.h>#include "defines.h"#include "spi.h"int main(void) {WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer/* --- Set Oscillator Settings (8Mhz) --------------- */// Set DCO to 5, MOD to 0DCOCTL = DCO2 | DCO0;// Set RSEL to 13BCSCTL1 = RSEL3 | RSEL2 | RSEL0;// MCLK = DCO/1, SMCLK = MCLK/8BCSCTL2 = SELM_0 | DIVM_0 | DIVS_3;// LFXT1 = VLOCLK, 1pF terminationBCSCTL3 = LFXT1S_2 | XCAP_0;// Disable oscillator fault interruptIE1 &= ~OFIE;/* -------------------------------------------------- *//* --- Set Port Settings ---------------------------- */// Set ports 1.5/1.6 as outputs// Set remaining ports as inputsP1DIR = BIT5 | BIT6;P2DIR = 0x00;// Enable pull-down resistorsP1REN = ~(BIT5 | BIT6);P2REN = 0xFF;// Set initial port valuesP1OUT = 0x00;P2OUT = 0x00;/* -------------------------------------------------- *//* --- Set USI Settings (SPI) ----------------------- */// Enable SDA/SCL/SCLK ports, MSB->LSB, master mode, output enabledUSICTL0 = USIPE7 | USIPE6 | USIPE5 | USIMST | USIOE;// I2C disabled, counter interrupt enabledUSICTL1 = USIIE;// SMCLK/1, SMCLK source, idle lowUSICKCTL = USIDIV_0 | USISSEL_2;// Enable USI module (clear reset bit)USICTL0 &= ~USISWRST;/* -------------------------------------------------- */// Write 0 to the counter to trigger the USI interrupt// USICNT = 0;// Go into low power mode with interrupts enabled_BIS_SR(LPM0_bits + GIE);}#pragma vector=USI_VECTOR__interrupt void USI_SPI_Vector(void) {char value = USISR;USISR = 0xAB;USICNT = 8;}