Hello all,
I've been trying to get the Serial Peripheral Interface to work for the TI MSC1211. I need to pass the signal into a D2A (a TLC5628), and have at the output a DC output. Since I'm just testing it, I just want to set it in the main part of the program (no interrupts or user input.....yet).
For this D2A, I need to send 12 bits, the first four set up the D2A (it has several outputs), and then the final eight are the actual value that the output should take.
So, here's my code:
void main ( void ) { PDCON = 0x00; PCON &= 0x7F; SCON0 = 0x50; /* SCON: mode 1, 8-bit UART, enable rcvr*/ TMOD |= 0x20; /* TMOD: timer 1, mode 2, 8-bit reload*/ TH1 = 0xFD; /* TH1: reload value for 19200 baud @ 22.1184 MHz */ TR1 = 1; /* TR1: timer 1 run */ PDCON&=~0x01; P1DDRH=0x55; P1DDRL=0x55; SPICON=0xC4; SPITCON=0x28; //autobaud(); P1_0 = 1; P1_2 = 1; // set LOAD high DelayMs(2000); SPIDATA = 0; // load SPIDATA SlaveSelect = 1; //set SS low to begin transmission Delay1us(1); // delay to allow message to transmit SlaveSelect = 0; // bring SS high again SPITCON = 0x08; // stop clock P1_7 = 0; //set clock to zero SPIDATA = 128; // ready data to be sent SPITCON = 0x28; // drive clock SlaveSelect = 1; // set SS low to begin transmission Delay1us(1); // delay to allow message to transmit SlaveSelect = 0; // bring SS high again P1_2 = 0; //set LOAD low to bring data Delay10us(1); //hold LOAD low P1_2 = 1; // set LOAD back high while (1){ } }
I'm not sure about the "autobaud()" part which I've commented out; I saw it in an example program, but I'm not sure what it does.
Thanks for any help (and I hope the code is clear),
Sunil