AnsweredAssumed Answered

ADT7310 continuous mode Pic24f

Question asked by kjlarkin on Jan 2, 2013
Latest reply on Jan 4, 2013 by jtowey



I am working with the ADT7310 temperature sensor and am trying to use it in continuous mode and grab some temperature information.  At the moment im almost sure im doing this incorrectly. 


Basically, i was trying to set it up into 13 bit format in continuous mode.  However, the values im getting returned start at about 17032 and fall by values of two for a while no matter what i do.  This may be a silly question, but i am just starting to get into programming things like this and am at a loss for what i am doing wrong, and any help would be greatly appreciated.


here is my current code:



        TRISCbits.TRISC2        = 1;

        TRISCbits.TRISC2        = 0;

        SPI2BUF = 0x80;

        SPI2BUF = 0x00;

        TRISCbits.TRISC2      =1;


unsigned int temp;

    unsigned int temp1;

    unsigned int temp2;



    TRISCbits.TRISC2        = 0;        // Bring CS low (begin write)

    SPI2BUF = 0x54;                     // Continuous read

    TRISCbits.TRISC2        = 1;        // Bring CS high (end of write)



    SPI2BUF=0x00;                       // Send 8 bits of dummy data

    temp = SPI2BUF;                     // Store 8 bits of temperature data




    while(TMR1<10);                     // Wait a unimportant amount of time




    SPI2BUF=0x00;                       // Send 8 bits of dummy data

    temp1 = SPI2BUF;                    // Store next 8 bits of temperature data



    temp = ((temp<<8));                 // Temp shifted 8 bits to the left (msb)

    temp2 = ((temp)|(temp1));             // Temp and temp1 are added together






    return temp2;                       // Return  latest temperature