Connect with us

reading from adc3550 with PIC

Discussion in 'Electronic Design' started by merco, Feb 27, 2009.

Scroll to continue with content
  1. merco

    merco Guest

    Hi to all.
    I'd like to use built in uC (mikroe.com) routines to read data from
    microchip adc 3550.
    At page 21 of the datasheet...
    Quote:

    It is required that the microcontroller SPI port be config-
    ured to clock out data on the falling edge of clock and
    latch data in on the rising edge. Figure 5-6 depicts the
    operation shown in SPI mode 1,1, which requires that
    the SCK from the MCU idles in the High state, while
    Figure 5-7 shows the similar case of SPI Mode 0,0,
    where the clock idles in the Low state. The waveforms
    in the figures are examples of an MCU operating the
    SPI port in 8-bit mode, and the MCP3550/1/3 devices
    do not require data in 8-bit groups.
    In SPI mode 1,1, data is read using only 24 clocks or
    three byte transfers. The data ready bit must be read
    by testing the SDO/RDY line prior to a falling edge of
    the clock.
    In SPI mode 0,0, data is read using 25 clocks or four
    byte transfers. Please note that the data ready bit is
    included in the transfer as the first bit in this mode.



    How can these differents mode could be done ?
    Now i'm trying this...

    Code:

    void Spi_INIT_my() {
    Spi_Init_Advanced
    (MASTER_OSC_DIV4,DATA_SAMPLE_END ,CLK_IDLE_LOW,LOW_2_HIGH) ;
    SSPSTAT=0xC0;
    SSPCON=0x20;
    TRISB.F2=0;
    TRISB.F1=1;
    TRISB.F6=0;
    }

    void Get_ADC_Value() {

    unsigned long appo;
    pin_CS_ADC=0;
    b3=Spi_Read(0);
    b2=Spi_Read(0);
    b1=Spi_Read(0);

    pin_CS_ADC=1;
    delay_ms(100);
    valore_ADC=0;
    appo=b3;
    appo=appo << 16;
    valore_ADC=valore_ADC+appo;
    appo=b2;
    appo=appo << 8;
    valore_ADC=valore_ADC+appo;
    appo=b1;
    valore_ADC=valore_ADC+appo;
    }



    And put these bytes over usart. I see first 3 bytes with correct value
    (i suppose), then 3 byte at 255, then another 3 byte with correct
    value ... and so on ...

    I would like to use SPI Communication – Mode 1,1 shown in figure
    5-6... Is this possibile with uC prebuilt routines ?

    Thank you
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-