Quantcast
Channel: Microcontrollers
Viewing all articles
Browse latest Browse all 216550

Forum Post: RE: MSP430G2452 and SPI Memory

$
0
0

Now I testing USCI module, I test write 0x11 on SPI, but signal is not valid for logic analyzer

#include "msp430.h"
#include <signal.h>

unsigned char MST_Data;

void main(void)
{
  WDTCTL = WDTPW + WDTHOLD;                                         // Stop watchdog timer

  P1DIR |= BIT5;
  P1SEL = BIT1 + BIT2 + BIT4;
  P1SEL2 = BIT1 + BIT2 + BIT4;
  UCA0CTL1 = UCSWRST;
  UCA0CTL0 |= UCCKPL + UCMSB + UCMST + UCSYNC + UCPAR + UCPEN;      // 3-pin, 8-bit SPI master
  UCA0CTL1 |= UCSSEL_2;                                             // SMCLK
  UCA0BR0 |= 0x02;                                                  // /2
  UCA0BR1 = 0;
  UCA0MCTL = 0;                                                     // No modulation
  UCA0CTL1 &= ~UCSWRST;                                             // **Initialize USCI state machine**
  IE2 |= UCA0TXIE;                                                  // Enable USCI0 TX interrupt

  MST_Data = 0x11;                                                  // Initialize data values

  UCA0TXBUF = MST_Data;                                             // Transmit first character

  while(1)
  {
      __bis_SR_register(LPM4_bits + GIE);                           // Enter LPM4, enable interrupts
  }

}

#pragma vector=USCIAB0TX_VECTOR
interrupt (USCIAB0TX_VECTOR) USCIA0RX_ISR(void)
{
  while (!(IFG2 & UCA0TXIFG));                                      // USCI_A0 TX buffer ready?

  UCA0TXBUF = MST_Data;                                             // Send next value
}


Viewing all articles
Browse latest Browse all 216550

Trending Articles