This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/MSP430G2755: Spi UCB0RXBUF receive only 0x00

Part Number: MSP430G2755


Tool/software: Code Composer Studio

Hello,

I receive only 0x00 data in UCB0RXBUF from an AD7689 adc, and i don't know why. I would like to get datas from a pressure sensor.

My code is:

#include <msp430.h>
char spiReadByte(void);
/*
* main.c
*/
int main(void) {
int i;
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
P1DIR=BIT0; // make pin 0 output
P1OUT=BIT0; // make pin 0 high
P2DIR=BIT0+BIT1;
P2OUT=0;

P3OUT = 0x40; // Set slave reset
P3DIR |= 0x40; //
P3SEL |= 0x0E; // P3.0,1,2,3 USCI_B0 option select
UCB0CTL0 |= UCCKPL | UCMSB | UCMST | UCSYNC; // 3-pin, 8-bit SPI master
UCB0CTL1 |= UCSSEL_2; // SMCLK
UCB0BR0 |= 0x02; // /2
UCB0BR1 = 0; //
UCA0MCTL = 0; // No modulation
UCB0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
IE2 |= UCB0RXIE; // Enable USCI0 RX interrupt

P3OUT &= ~0x40; // Now with SPI signals initialized,
P3OUT |= 0x40; // reset slave

for (i = 50; i > 0; i--); // Wait for slave to initialize -

for(i=2; i>0; i--) //DIN-t 2 beszélgetésig high-ba
{spiReadByte();}

//while (!(IFG2 & UCB0TXIFG));
//UCB0TXBUF = /*config adc hexaba*/; // Transmit first character

//printf("%d\n", spiReadByte());
while(1)
{spiReadByte();}

}

char spiReadByte(void)
{
char adat;
// wait for tx
while (!(IFG2 & UCB0TXIFG)); // This only tells you when the TX buffer is empty.

UCB0TXBUF = 0xAA;

while (!(IFG2 & UCB0RXIFG));

adat=UCB0RXBUF;

return adat;
}

  • Hello Gergely,

    The AD7689 is active when CNV is low, however your code currently continues to drive it high with P3.6. You must also follow all timing specifications from Table 5 of the AD7689 datasheet. Please also study the Digital Interface section of this datasheet, specifically timing Figure 39. The clock polarity is shown active low (UCCKPL cleared) and data captured on the first UCLK edge (UCCKPH set).  Provide oscilloscope or logic analyzer screenshots if possible.

    Regards,
    Ryan

**Attention** This is a public forum