Aichibo
Newbie level 2
Hey, I've come on a bit since I was initially trying to get my programming skills up to scratch to even make an LED flash.
My next task is to try and get the MSP430 chip I've been working with to "talk" to an LTC1960 via SPI. I think I've set it up correctly.. can anyone see any problems with this?
Thanks
My next task is to try and get the MSP430 chip I've been working with to "talk" to an LTC1960 via SPI. I think I've set it up correctly.. can anyone see any problems with this?
Code:
#include "msp430x22x4.h"
void spiInit(void);
void main(void)
{
volatile int i,j;
spiInit();
while (1)
{
UCB0TXBUF = 0x20; // Dummy Write
for(i=0;i<10000;i++); // Wait a while
{
for(j=0;j<10;j++);
}
}
}
void spiInit(void)
{
UCB0CTL0 = 0x17; // SPI, 8 bit data, no loopback, SPI mode, master, reset
UCB0CTL1 = 0xa1; // CKPH=1, CKPL=0, SMCLK, 4 pin mode, Tx empty
UCB0BR0 = 2; //SMCLK divider
UCB0BR1 = 0;
IE1 &= ~0x80; // disable SPI interrupts
IE1 &= ~0x40;
P3SEL |= 0x39; // P3 bits 0,3,4,5 as spi
P3DIR |= 0x19; // P3 bits 0,3,4 as output
P3DIR |= 0x20; // P3 bit 5 as input
UCB0CTL0 &= ~1; // release reset
UCB0TXBUF = 0x00; // Dummy Write
}
Thanks