Hi! I'm programming cc430f6137 SPI to use micro as master and communicate with tmp124 temperature sensor. My problem is the clock UCA0CLK. On the clock spi PIN there's nothing. The code is the following:
#include <CC430F6137.h>
double received= 0;
void main(void)
{
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
PMAPPWD = 0x02D52; // Get write-access to port mapping regs
P2MAP0 = PM_UCA0SIMO; // Map UCA0SIMO output to P2.0
P2MAP2 = PM_UCA0SOMI; // Map UCA0SOMI output to P2.2
P2MAP4 = PM_UCA0CLK; // Map UCA0CLK output to P2.4
PMAPPWD = 0; // Lock port mapping registers
P1DIR=0x80;
P1OUT |= 0x80;
P2SEL |= BIT0 + BIT2 + BIT4;
P2DIR |= BIT0 + BIT2 + BIT4;
UCA0CTL1 |= UCSWRST; // **Put state machine in reset**
UCA0CTL0 |= UCMST+UCSYNC+UCCKPL+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 |= UCTXIE;
__bis_SR_register(LPM0_bits + GIE);
__delay_cycles(1000);
}
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
{
while(1)
{
P1OUT &= ~0x80; // Port 2.7
P2SEL |= BIT0 + BIT2 + BIT4;
while (!(UCA0IFG&UCTXIFG)); // USART0 TX buffer ready?
received= UCA0RXBUF;
// __delay_cycles(17);
P1OUT |= 0x80; // Port 2.7
__no_operation();
}
}
thanks
Dan