This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello,
I try to use Launchpad to comunicate with an external DAC on USCIB SPI_BUS.
But I do not have enough information how I can configure the SPI for my requirements.
I have configure 3 wire SPI with SLCK=1MHZ and 16bit data. Is there a example or documentation regarding the SPI registers?
I foun the code but only with 8 bit data;
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**
I will apreciate any help.
Yeah! There are many!
Are you using CCS5? You can get examples in the TI resource explorer.
This is the sample code msp430g2xx2_usi_05, for example ;)
#include <msp430g2452.h>
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1OUT = 0;
P1DIR |= 0x03;
USICTL0 |= USIPE7 + USIPE5 + USIMST + USIOE; // Port, SPI master
USICTL1 |= USIIE; // Counter interrupt, flag remains set
USICKCTL = USIDIV_2 + USISSEL_2; // /4 SMCLK
USICTL0 &= ~USISWRST; // USI released for operation
USICNT = 8; // init-load counter
_BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/ interrupt
}
// USI interrupt service routine
#pragma vector=USI_VECTOR
__interrupt void universal_serial_interface(void)
{
P1OUT |= 0x02; // Disable TLC549
if (USISRL > 0x7F)
P1OUT |= 0x01;
else
P1OUT &= ~0x01;
P1OUT &= ~0x02; // Enable TLC549
USICNT = 8; // re-load counter
}
If not using CCS5, you can download examples from here:
Find your chip, get the zip with the examples, read the README within the zip to see the names of the correct examples, and choose the SPI example (I think there are 6) more similar to your question.
Good luck!
PS: You have more documentation here:
http://www.ti.com/lit/ug/slau144i/slau144i.pdf
And in docs like these:
http://www.ti.com/lit/ds/symlink/msp430g2152.pdf
SPI is synchronous. For each bit sent adn received, one clock pulse is generated.
There is no difference between 16 bit and 2*8 bit transfer.
**Attention** This is a public forum