This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

interfacing LPC2368 with DS1820

Hi ,
I have problems with interfacing DS1820 to LPC2368. i can see only "127" on display. Thnks.

Parents
  • I have big problems understanding your question.

    Do you have a problem communicating with the DS1820, or with the display or something else.

    You don't supply much facts, so you can't expect much responses.

    Start by exmpalinging what you have done - and how you have connected the hardware - and how you have deduced which block of your code that is having problems. And what you have done to try to figure out why the code - or hardware - doesn't do what you want it to.

Reply
  • I have big problems understanding your question.

    Do you have a problem communicating with the DS1820, or with the display or something else.

    You don't supply much facts, so you can't expect much responses.

    Start by exmpalinging what you have done - and how you have connected the hardware - and how you have deduced which block of your code that is having problems. And what you have done to try to figure out why the code - or hardware - doesn't do what you want it to.

Children
  • Hi,

    I have problems with communicating LPC2368 and DS1820

    I connected DS1820 to P2.7 pin of LPC. and 4.7K to Vdd of LPC.

    i connected DS1820 's Vdd pin to 5Vdc. Because in datasheet i saw that DS1820's working voltage is between 3.6V - 5V. LPC Vdd is 3.2V

    And here is my code :

    ----------------------------------------------------

    #define DQ_SET FIO2SET |= 0x00000080;
    #define DQ_CLR FIO2CLR |= 0x00000080;

    void onewire_reset()

    {

    FIO2DIR = 0XFFFFFFFF; FIO2MASK = 0xFFFFFF00;

    DQ_CLR delay_us(600); DQ_SET delay_us(600); DQ_CLR

    }

    void command(BYTE data) { int i;

    FIO2DIR = 0XFFFFFFFF; FIO2MASK = 0xFFFFFF00;

    for(i=0; i<8; i++) {

    DQ_CLR

    delay_us(16);

    if (data & 1 << i) DQ_SET

    else DQ_CLR

    delay_us(240);

    DQ_SET

    delay_us(16);

    } }

    int read_bit() { int bit=1;

    FIO2DIR = 0XFFFFFFFF; FIO2MASK = 0xFFFFFF00;

    DQ_CLR

    delay_us(16);

    DQ_SET

    delay_us(16);

    FIO2DIR = 0XFFFFFF7F; FIO2MASK = 0xFFFFFF00;

    if(!(FIO2PIN & 128)) bit=0;

    return bit;

    }

    unsigned char read_byte(void)
    { unsigned char i;
    unsigned char value = 0;

    for (i=0;i<8;i++)
    { if( read_bit() ) value|= 1 << i; delay_us(240);

    }
    return(value);
    }

    unsigned char Read_Temperature(void)
    { int lsb=0; int msb=0; int temp=0; float temp_c=0;

    onewire_reset();

    command(0xCC); command(0x44);

    onewire_reset();

    command(0xCC); command(0xBE);

    msb = read_byte(); // Read msb

    lsb = read_byte();

    temp = msb<<8 + lsb;

    temp_c = (temp>>5) * 0.125;

    sprintf(sicaklik_deger,"T:%2.1f",temp_c);

    return(1);

    }

  • You don't seem to read the presence pulse after the reset.

    When reading, you generate a 16us pulse and then read the bit after a further 16us. But shouldn't you read within the first 15us from the start of the read operation?

    Have you verified - by sampling the signal continuously after starting a read cycle - that you can see both a zero and a one from the sensor?

    Have you used an oscilloscope to verify the signal?

    You don't seem to emit any debug output. You should verify what happens long before you get to the conversion to a floating point value. By the way - you don't need floating point for printing the temperature. You can used fixed-point integers instead.

  • what is maximum frequency you want to use?

    Well, that depends of a lot of things:

    Which frequency you are using to clock the code?
    What is the language you will use in the project when you worked? Assembler ?, C ? Basic?
    Who long is the code inside the interrupt?

  • Did you post in the wrong thread?

    You can't choose the communication frequency for the DS1820. You can choose how long to pause between each bit (infinity is ok as long as the device stays powered), but the bit timing for the communication is dictated by the datasheet. It isn't like I2C where you configure a baudrate, and then clock the data synchronously.

  • i use c language.

    Here are the frequencies :

    /* Clock Definitions */
    #define Fosc 12000000
    /* System frequence,should be less than 80MHz. */
    #define Fcclk 57600000
    #define Fcco 288000000

    i testes several pauses , but at all of them there is no different result.

  • See the Datasheet for the answer to this question!

  • can DS1820 run at 3.2V ?

    Now it occurs to you to ask yourself that? After you've written all this code based on the vague assumption that the hardware just might work?

    I strongly suggest you reconsider your work flow. HW interface issues should be dealt with before you start designing software.