Quantcast
Channel: MSP low-power microcontroller forum - Recent Threads
Viewing all articles
Browse latest Browse all 22218

CCS: ADXL362 with MSP430F5529LP

$
0
0

Tool/software: Code Composer Studio

HI,

        i have interfaced adxl362 to the msp430f5529 lp using the spi interface (USCI A0) and am trying to read the device id of the adxl ic but there is no output, please help me with the code and also want to write to the adxl362 register, so how should i proceed with as well?

below is the code

#include "msp430.h"
#include <msp430f5529.h>


int i,k;

char devid,dataform;

unsigned char read_byte(unsigned char byte)
{
	UCA0IFG &= ~UCRXIFG;
	UCA0TXBUF = byte;
	while(!(UCA0STAT & UCBUSY));
    UCA0TXBUF = 0xff;
    while(!(UCA0STAT & UCBUSY));
	return UCA0RXBUF;
}



void main(void)

{
	WDTCTL = WDTPW+WDTHOLD;                   // Stop watchdog timer

P3SEL |= BIT3+BIT4;                       // P3.3,4 option select
  P2SEL |= BIT7;                            // P2.7 option select

  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 |= UCRXIE;                         // Enable USCI_A0 RX interrupt

  P3OUT &= ~BIT2;
  read_byte(0x0B);                  /// command to read
 devid = read_byte(0x00);                  //address to read


  P3OUT |= BIT2;
}


Viewing all articles
Browse latest Browse all 22218

Trending Articles



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