Hi! i'm programming cc430f6137 to communicate with tmp124. I need help because i obtain always 0xFF. Probably i wrong configuration of spi.
Code is following:
#include "cc430x613x.h"
volatile unsigned char received= 0;
void main(void)
{
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
PMAPPWD = 0x02D52; // Get write-access to port mapping regs
P1MAP6 = PM_UCA0SIMO; // Map UCA0SIMO output to P2.0
P1MAP5 = PM_UCA0SOMI; // Map UCA0SOMI output to P2.2
P1MAP7 = PM_UCA0CLK; // Map UCA0CLK output to P2.4
PMAPPWD = 0; // Lock port mapping registers
P4DIR |=0x80;
P4OUT |=0x80;
P1DIR |= BIT6 + BIT7;
P1SEL |= BIT5 + BIT6 + BIT7;
UCA0CTL1 |= UCSWRST; // **Put state machine in reset**
UCA0CTL0 |= UCMST+UCSYNC+UCCKPH+UCMSB; // 3-pin, 8-bit SPI master
// Clock polarity high, MSB
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 0x02; // /2
UCA0BR1 = 0; //
UCA0MCTL = 0; // No modulation
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt
P4OUT &= ~BIT7; // Now with SPI signals initialized,
P4OUT |= BIT7; // reset slave
__delay_cycles(100); // Wait for slave to initialize
while (!(UCA0IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
P4OUT &= ~BIT7;
UCA0TXBUF = 0x00; // Transmit first character
__delay_cycles(20);
__bis_SR_register(LPM0_bits + GIE); // CPU off, enable interrupts
}
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
{
switch(__even_in_range(UCA0IV,4))
{
case 0: break; // Vector 0 - no interrupt
case 2: // Vector 2 - RXIFG
received= UCA0RXBUF;
// P4OUT &= ~0x80;
break;
case 4: break; // Vector 4 - TXIFG
default: break;
}
}