Part Number: LDC1101
Hallo everyone,
I am trying to configure the LDC1101 chip via SPI protocol using a MSP430 microcontroller. The main goal is to read the LHR data contained in it. I send the configurations via 2 bytes containing address and data. Unfortunately, the registers seem to remain unchanged and I do not receive response; any signal on the MISO pin. Does anyone know where I am wrong, or if something is missing in the code? What I need is simply to get the data from the sensor...
ps. Then I post the signals of the logic analyzer and my code
Thank you very much.
#include <msp430.h>
#include <rf430frl152h.h>
#include <stdio.h>
void spiConfig();
void regSettings();
void TI_CC_SPIWriteReg(char addr, char value);
volatile char received_ch = 0;
/**
* main.c
*/
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
spiConfig();
regSettings();
return 0;
}
void spiConfig()
{
UCB0CTLW0 |= UCSWRST; //reset, if not..config is not possible
/*************************************************************
* ---------- configuration of SPI interface MSP430 ----------
************************************************************/
P1OUT |= 0x08;
P1DIR |= 0x08; // Enable, output direction
P1SEL0 |= 0x07; // CLK, MOSI, SOMI, CS option select registers
P1SEL1 &= ~0x07;
UCB0CTLW0 |= UCMST | UCSYNC | UCMSB ;// 4 pin(mode_3), 8 bit SPI mstr, MSB first
UCB0CTLW0 |= UCSSEL_2; // SMCLK as clock source
UCB0BR0 |= 0x02;
UCB0BR1 |= 0;
UCB0CTLW0 &= ~UCSWRST; // init USCI state machine by pulling the reset low, "ENABLE spi"
}
void regSettings()
{
/**********************************************************************************
* --------- configuration for LDC1101, send data needed to configure it ----------
*********************************************************************************/
// !! sleep mode needed to configure the LDC chip !!
TI_CC_SPIWriteReg(0x0B,0x01);
// Only LHR measurement
// TI_CC_SPIWriteReg(0x05,0x01);//shutdown,reset register
// TI_CC_SPIWriteReg(0x0B,0x02);//shutdown, clock low
// TI_CC_SPIWriteReg(0x0C,0x01);
// Read LHR only
// TI_CC_SPIWriteReg(0x0A,0x20);
// TI_CC_SPIWriteReg(0x32,0x00);//LHR offset
// TI_CC_SPIWriteReg(0x34,0x00);//LHR config reg
// TI_CC_SPIWriteReg(0x3E,0x00);//device value
// TI_CC_SPIWriteReg(0x3F,0x00);//device ID
// Register settings for LHR application
TI_CC_SPIWriteReg(0x01,0x07);
TI_CC_SPIWriteReg(0x04,0xE7);
TI_CC_SPIWriteReg(0x30,0x4A);
TI_CC_SPIWriteReg(0x31,0x01);
/***********************************************
* --------- sensor DATA transmission ----------
**********************************************/
// command to request MISO LHR data ??
TI_CC_SPIWriteReg(0xB8,0x00 ); // read register LHR command, reg 0x38
// !! return to conversion mode !!
TI_CC_SPIWriteReg(0x0B,0x00);
}
void TI_CC_SPIWriteReg(char addr, char value) //first byte is register, second byte is data
{
P1OUT &= ~0x08; // CS enable by pulling CSn low
UCB0IFG &= ~UCTXIFG; // Clear flag
UCB0TXBUF = addr; // send Address by putting in SPI buffer
while(!(UCB0IFG & UCTXIFG)); // Wait for TX to finish (status byte receive)
UCB0IFG &= ~UCTXIFG; // Clear Flag
UCB0TXBUF = value; // Send data
while(!(UCB0IFG & UCTXIFG)); // Wait for TX to finish (status byte receive)
__delay_cycles(10);
// UCB0IFG &= ~UCRXIFG;
// received_ch = UCB0RXBUF;
// while(!(UCB0IFG & UCRXIFG)); // Wait for TX to finish (status byte receive)
P1OUT |= 0x08; // Pull CS high to disable SPI
//__delay_cycles(100);
}
