Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

ads1292R initialization

$
0
0

hello,

firstly, sorry for my english (I realize it can quite poor)

I'm trying to initialize an ADS1292R using ATmega8 (MCu is not very important here) and my code doesn't work.

I checked connections on PCB 10 times and I believe they're good.

PWDN/RES pin is tied to Vcc (about 3,6V) by resistor 1k, CLSEL is tied to VCC with no resistor. 

 All necessary comments are included in code, I hope.

This is my code (it's aim is to initialize ADS1292 and read some registers):

 void ads_init(char *cBuf)
{
    uint8_t num_of_regs_to_be_read;

    DDRB |= (1<<MOSI) | (1<<SCK) | (1<<PB2); //configuration of SPI interface, transmission from MSB
    PORTB &= ~(1<<PB2); //f_sclk 125kHz
    SPCR |= (1<<SPE) | (1<<MSTR) | (1<<CPHA) | (1<<SPR1); //SCLK is low when idle, uC setups at leading edge and samples at      //trailing edge

    _delay_ms(2000); // Delay for Power-On Reset and Oscillator Start-Up

    SPDR = 0x06; //transmit RESET command
    while(!(SPSR & (1<<SPIF)));

    _delay_ms(100); //Wait for 18 tCLKs (much more)

    SPDR = 0x11; //transmit SDATAC command
    while(!(SPSR & (1<<SPIF)));

    _delay_ms(1); //Wait for 4 tCLKs (much more)

    SPDR = 0x20; //read registers from address 0x00
    while(!(SPSR & (1<<SPIF))); 

    SPDR = 0x04; //5 registers to be read
    while(!(SPSR & (1<<SPIF))); 

    num_of_regs_to_be_read = 5;

    while (num_of_regs_to_be_read--) //read registers
    {
       SPDR = 0x00;
       while(!(SPSR & (1<<SPIF)));
       *cBuf++ = SPDR;
       }
}

 Could anyone tell me what's wrong with this? Or give me a sample code in C to initialize ADS1292R and read some registers?

 


Viewing all articles
Browse latest Browse all 262198

Trending Articles



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