EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / one wire communication

one wire communication

|

Microcontroller › 8051 › one wire communication

  • This topic has 5 replies, 3 voices, and was last updated 14 years, 9 months ago by dagakshay.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • August 2, 2011 at 10:40 am #1239
    lucky
    Participant

    Hi..

       I am trying to interface DS2433 with 8051. i have written code according to protocol but i am not able to write data into EEPROM can any one help me…..

     

    Thanks &Regards,

    lucky

    August 3, 2011 at 6:30 am #6561
    lucky
    Participant

    Hi,

     

     

     
    void main()
     {
      unsigned char i,dat[5];
    reset();
    write_byte(0xCC); //skip rom command
    write_byte(0x0F); //write scratchpad
    write_byte(0x00);   //TA1 – data
      write_byte(0x00);   //TA2 – data
      write_byte(10);   //data to memory location 0x10
      write_byte(14); 
    reset();
    write_byte(0xCC);   //skip rom command
    write_byte(0xAA); //read scratchpad command
    for(i=0;i<5;i++)
    {
    dat=read_byte(); 
    }
    reset();
    write_byte(0xCC); //skip rom command
    write_byte(0x55); //copy scratchpad
    write_byte(0x00);   //TA1 – data
      write_byte(0x00);   //TA2 – data
    write_byte(0x01); //ending off set
    ms_delay(5);
    reset();
    // while(1);
     }
     
    void reset(void)
     {
      unsigned char presence;
    write0();
      ms_delay(500);   //480
      write1();
      ms_delay(80); //70
      presence = read_bit();
      ms_delay(420);   //410
      write1(); //– not required
     }
     
    void write_byte(unsigned char w_buff)
     {
    unsigned char w_cnt = 0;
    // P3=w_buff;
    while(w_cnt<8)
    {
    // P2=w_buff;
    if(w_buff & 0x01) //to send LSB first
    {
      write1();
    }
    else
     {
      write0();
     }
    w_buff = w_buff >> 1;
    w_cnt++;
    }
     }
     
    unsigned char read_byte(void)
     {
    unsigned char temp=0,r_cnt=0,r_buff;
    while(r_cnt<8)
    {
    temp = read_bit();
    if(temp)
    {
     r_buff |= 1;
    }
    r_buff=r_buff << 1;
    r_cnt++;
    }
    P3=r_buff;
    return(r_buff); 
     }
     
    void write0(void)
     {
    ds=0;
    ms_delay(70);  //actual delay 60us
        ds=1;
    ms_delay(10);
     }
     
    void write1(void)
     {
      ds=0;
    ms_delay(10);  //actual delay 6us
    ds=1;
    ms_delay(65);  //actual delay 54us
     }
     
    unsigned char read_bit(void)
     {
      unsigned char result;
    ds=0;
    ms_delay(10);   //actual delay 6us
    ds=1;
    ms_delay(19);   //actual dealay 11us
    result=ds;
    ms_delay(60);   //sctual delay 45us
    return(result);
     }
     
    this is my code for writing data into memory, coming to circuit iam using proteus..in that i was connected data pin of eeprom to port pin and i was connected a pullup to that wire…..
     
     
    August 3, 2011 at 1:01 pm #6564
    romel emperado
    Participant

    you can also try the i2c the two wire interface eeprom if you want..

     

    here are some tutorials:

     

    http://adf.ly/2Gxqm

     

    http://adf.ly/2Gy5n

    August 8, 2011 at 10:47 am #6591
    lucky
    Participant

    Ok,

    i will try with proper hardware… 

     

    Thanks & Regards,

    lucky

    August 8, 2011 at 10:49 am #6592
    lucky
    Participant

    Here in one wire communication , i need to give delay in microseconds like some times i need to provide 10 micro seconds delay ,Is it possible to produce such a delays…

    August 12, 2011 at 7:57 am #6598
    dagakshay
    Participant

    yes you can provide a mini of 1.085 micro second delay uing 8051 timers….

  • Author
    Posts
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Smart Buoy project May 15, 2026
  • Need Guidance to reduce noise in 3-stage Transimpedance amplifier May 15, 2026
  • Wall Radiator Heating: Efficiency and Placement Questions May 15, 2026
  • Parasitic Draw Question May 15, 2026
  • Phone Charger 5v to 12v May 14, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise