Other Parts Discussed in Thread: MSP430F5529, LMP91200
I am trying to use the MSP430F5529 launchpad to interface with the LMP91200 using the code included with the LMP91200. But I am not getting communication between the devices and the code goes into an error to blink LED continuously. When I put a scope probe on the UCA0CLK pin (P2.7) there is no clock signal (it remains high at 3.3V). If I step through the program, P2.7 goes from low to high when the TI_LMP91200_SPISetup function finishes. Why is there no clock signal? And what can I do to fix it?
#include <stdint.h>
#include <msp430f5529.h>
#include "TI_LMP91200.h"
#include "TI_LMP91200_register_settings.h"
#include "TI_MSP430.h"
#include "TI_MSP430_hardware_board.h"
#include "TI_MSP430_spi.h"
#include "TI_MSP430_spi_USCIA0.h"
void ADC12_Init(void); // To init MSP430F5528 ADC12 & Start Conversion
#define TI_LMP91200_VOUT_ADC12_PxSEL P6SEL // ADC12 A6 channel on P6.6 (MSP430F5528)
#define TI_LMP91200_VOUT_ADC12_PIN BIT6
#define NUM_OF_RESULTS 8 // Number of temp sensor samples to take
#define SCALE_FACTOR 3 // For averaging converted samples
#define PT_RES_NOMINAL 100 // 100ohms at 0degC
#define ADC12_RATIO 0.6105 // 2500/4095 (2.5V reference & 12bit converter)
#define ADC14_RATIO 0.15259 // 2500/16384(2500mV ref & 14bit converter w/ 2's comp o/p)
#define PT_TC 0.3850 // PT_TC is ohms/degC
#define PGA_GAIN 10 // Gain of 10
#define I_VALUE 1 // 1mA
#define R_REF 100 // 100ohm reference resistor
//******************************************************************************
void main(void)
{
uint16_t reg_write_data, reg_read_data;
WDTCTL = WDTPW+WDTHOLD; // Stop WDT
TI_LMP91200_LED_PxOUT |= TI_LMP91200_LED_PIN; // Set LED ON
TI_LMP91200_LED_PxDIR |= TI_LMP91200_LED_PIN; // Set pin direction is output
//P2SEL=BIT2; //test SMCLK signal
//P2DIR=BIT2;
TI_LMP91200_SPISetup(); // Initilaize MSP430 SPI Block
reg_write_data = TI_LMP91200_CONFIG_REG_RTD_VALUE; // value to write (Temp Measurement, RTD, 1mA, PGA=10, VOCM=GND)
reg_read_data = TI_LMP91200_SPIWriteReg(reg_write_data); // Write again to read config register
reg_read_data = TI_LMP91200_SPIWriteReg(reg_write_data); // Write again to read config register
// test if write/read values match
if (reg_write_data != reg_read_data)
{
while (1) // error: blink LED continuously
{
__delay_cycles(250000);
TI_LMP91200_LED_PxOUT ^= TI_LMP91200_LED_PIN;
}
}
TI_LMP91200_SPIWriteReg(TI_LMP91200_CONFIG_REG_RTD_VALUE); // Measure RTD
ADC12_Init(); // Initialize MSP430F5528 ADC12 & Start Conversion
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0, Enable interrupts
__no_operation(); // For debugger
}
//*************************************************************************************************************
#include <stdint.h>
#include "TI_LMP91200.h"
#include "TI_MSP430.h"
#include "TI_MSP430_hardware_board.h"
#include "TI_MSP430_spi.h"
//******************************************************************************
// Support for 552x USCI_A0
//******************************************************************************
#if TI_LMP91200_SER_INTF == TI_LMP91200_SER_INTF_USCIA0_5xx
//------------------------------------------------------------------------------
// void TI_LMP91200_SPISetup(void)
//
// DESCRIPTION:
// Configures the assigned interface to function as a SPI port and
// initializes it.
//------------------------------------------------------------------------------
void TI_LMP91200_SPISetup(void) {
TI_LMP91200_CSn_PxOUT |= TI_LMP91200_CSn_PIN;
TI_LMP91200_CSn_PxDIR |= TI_LMP91200_CSn_PIN; // /CS disable
UCA0CTL1 |= UCSWRST; // **Disable USCI state machine**
UCA0CTL0 |= UCMST + UCCKPL + UCMSB + UCSYNC; // 3-pin, 8-bit SPI master
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 0x04; // UCLK/4
UCA0BR1 = 0;
UCA0MCTL = 0;
TI_LMP91200_SPI_USCIA0_SIMO_PxSEL |= TI_LMP91200_SPI_USCIA0_SIMO; // SPI option select
TI_LMP91200_SPI_USCIA0_SOMI_PxSEL |= TI_LMP91200_SPI_USCIA0_SOMI;
TI_LMP91200_SPI_USCIA0_UCLK_PxSEL |= TI_LMP91200_SPI_USCIA0_UCLK;
TI_LMP91200_SPI_USCIA0_SIMO_PxDIR |= TI_LMP91200_SPI_USCIA0_SIMO; // SPI TXD out direction
TI_LMP91200_SPI_USCIA0_UCLK_PxDIR |= TI_LMP91200_SPI_USCIA0_UCLK;
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
}
//------------------------------------------------------------------------------
// uint16_t TI_LMP91200_SPIWriteReg(uint16_t value)
//
// DESCRIPTION:
// Writes "value" to configuration register. Returns the previous value
// in the configuration register.
//------------------------------------------------------------------------------
uint16_t TI_LMP91200_SPIWriteReg(uint16_t value)
{
uint16_t x = 0;
uint8_t inst;
TI_LMP91200_CSn_PxOUT &= ~TI_LMP91200_CSn_PIN; // /CS enable
inst = value >> 8; // Get msb data to send
while (!(UCA0IFG & UCTXIFG)) // Wait for TXBUF ready
UCA0TXBUF = inst; // Send msb
while (UCA0STAT & UCBUSY) // Wait for TX complete
x = UCA0RXBUF; // Read previous msb
inst = value & 0x00FF; // Get lsb data to send
while (!(UCA0IFG & UCTXIFG)) // Wait for TXBUF ready
UCA0TXBUF = inst; // Send lsb data value
while (UCA0STAT & UCBUSY) // Wait for TX complete
x = (x << 8) | UCA0RXBUF; // Read previous lsb & append
TI_LMP91200_CSn_PxOUT |= TI_LMP91200_CSn_PIN; // /CS disable
return x; // return previous register value
}
//------------------------------------------------------------------------------
#endif
// SPI port definitions
// USCIA0 for F552x
#define TI_LMP91200_SPI_USCIA0_SIMO_PxSEL P3SEL
#define TI_LMP91200_SPI_USCIA0_SOMI_PxSEL P3SEL
#define TI_LMP91200_SPI_USCIA0_UCLK_PxSEL P2SEL
#define TI_LMP91200_SPI_USCIA0_SIMO_PxDIR P3DIR
#define TI_LMP91200_SPI_USCIA0_UCLK_PxDIR P2DIR
#define TI_LMP91200_SPI_USCIA0_PxIN P3IN
#define TI_LMP91200_SPI_USCIA0_SIMO BIT3
#define TI_LMP91200_SPI_USCIA0_SOMI BIT4
#define TI_LMP91200_SPI_USCIA0_UCLK BIT7
// Chip Select Pin
#define TI_LMP91200_CSn_PxOUT P2OUT
#define TI_LMP91200_CSn_PxDIR P2DIR
#define TI_LMP91200_CSn_PIN BIT5