Quantcast
Channel: MSP low-power microcontrollers
Viewing all articles
Browse latest Browse all 62309

Forum Post: Problem communicating between MSP430F5438A and ADS1248

$
0
0
I'm trying to communicate between MSP430F5438A and ADS1248 and I'm having problems. The ADS1248 is connected to UCB1. I've tried to create a small application to try to reproduce the problem (code is at the bottom) It does not work, but it does not behave the same as my real application... In my main application I'm using the interrupt handler (on UCRXIFG) to read the returned bytes from the SPI but I'm always getting 0's (I've tried reading Register 0 and also all registers 0-0x0e) In the demo application on the other have, the UCRXIFG is always 0, so the program just hangs on the while statement... This is new elecronics, so it might be a problem with the elecronics (we also have another question to make sure that we don't have a problem with the electronics https://e2e.ti.com/support/data_converters/precision_data_converters/f/73/t/521068 ) Thanks, Nadav //============================= #include #define WAKEUP 0x00 #define SLEEP 0x02 #define SYNC 0x04 #define RESET 0x06 #define NOP 0xFF #define RDATA 0x12 #define RDATAC 0x14 #define SDATAC 0x16 #define RREG 0x20 #define WREG 0x40 #define SYSOCAL 0x60 #define SYSGCAL 0x61 #define SELFOCAL 0x62 #define ADS1248 _START (BIT2) #define ADS1248 _RESET (BIT3) #define ADS1248 _CS (BIT0) void Init() { // + P3.7 * - SPI_MOSI // + P5.4 * - SPI_MISO // + P5.5 * - SPI_CLK P3SEL = BIT7; P5SEL = BIT4 | BIT5; // + P6.2 (OUT) - ADS1248 _START // + P6.3 (OUT) - ADS1248 _RESET // + P9.0 (OUT) - ADS1248 _CS // RESET=1 P6DIR = ADS1248 _START | ADS1248 _RESET; P6OUT = 0; P9DIR = ADS1248 _CS; P9OUT = 0; UCB1CTL1 |= UCSWRST; //SPI UCB1CTL0 = UCSYNC+UCMST+UCMSB; //UCB1CTL0 |= UCMST + UCSYNC + UCCKPL + UCMSB; // 3-pin, 8-bit SPI master UCB1CTL1 |= UCSSEL_2; UCB1BR0 = 8; UCB1BR1 = 0x00; UCA1CTL1 &= ~UCSWRST; __bis_SR_register(GIE); } int send(char c) { while (!(UCB1IFG & UCTXIFG)) ; UCB1TXBUF = c; // Transmit first character while (!(UCB1IFG & UCRXIFG)) ; int dummy = UCB1RXBUF; return dummy; } int read() { while (!(UCB1IFG & UCTXIFG)) ; UCB1TXBUF = NOP; // dummy while (!(UCB1IFG & UCRXIFG)) ; int dummy = UCB1RXBUF; return dummy; } void ADS1248AssertCS(int assert) { if (assert) { P9OUT &= ~ ADS1248 _CS; } else { P9OUT |= ADS1248 _CS; } } /* * main.c */ int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer volatile long temp = -1; Init(); /************************/ // ADS1248 Power UP P6OUT |= ADS1248 _START; //Start High P6OUT |= ADS1248 _RESET; //Reset High ADS1248AssertCS(1); //CS goes low //ADS1248AssertCS(0); //CS goes high __delay_cycles(8192); // 1MHz*8192=8ms /************************/ //Issue RDATAC command to allow results to load into output register /************************/ temp = UCB1RXBUF; send(WAKEUP); while(1) { send(RREG|0x01); send(0); temp = read(); __no_operation(); } char d[3]; while (1) { d[0] = read(); d[1] = read(); d[2] = read(); __no_operation(); } return 0; }

Viewing all articles
Browse latest Browse all 62309

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>