Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] Onewire RTC reading from DallasButton DS1994 for Pic18f452

Status
Not open for further replies.

rajib.das

Member level 3
Member level 3
Joined
Oct 23, 2013
Messages
54
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Visit site
Activity points
415
I would like to get help on the C code for reading RTC from Dallas Button DS1994 for Pic18f452.

I tried with the following code but not working..


Code:
void Read_Clock_Time_iButton(void) {



     Ow_Reset(&PORTB, 0);                         // Onewire reset signal
     Ow_Write(&PORTB, 0, 0xCC);                   // Issue command SKIP_ROM
     Delay_us(120);
     Ow_Write(&PORTB, 0, 0xF0);     //read memory command
     Ow_Write(&PORTB, 0, 0x02);  // send LSB of target addr then MSB
     Ow_Write(&PORTB, 0, 0x02);
     //Ow_Write(&PORTB, 0, 0x0202 & 0xFF);  // send LSB of target addr then MSB
     //Ow_Write(&PORTB, 0, (0x0202 & 0xFF00)/ 0x100);
     Ow_Write(&PORTB, 0, 0x33);
     Delay_us(120);                   // Issue command Read_ROM
     *iButton_fraction_seconds = Ow_Read(&PORTB, 0);

     //Ow_Write(&PORTB, 0, 0xFF);                   // Issue command Read_ROM
     for(k = 0; k <= 3; k++) {
        iButton_clock_data[k] = Ow_Read(&PORTB, 0);
     }
     *iButton_fraction_seconds = (*iButton_fraction_seconds)/256.0;          // convert value to fractional decimal secs
     //iButton_clock_data = iButton_clock_data[0]|(iButton_clock_data[1]*0x100)|(iButton_clock_data[2]*0x10000)|(iButton_clock_data[3]*0x1000000);
     iButton_seconds_total = iButton_clock_data[0] + (iButton_clock_data[1]*0x100) + (iButton_clock_data[2]*0x10000) + (iButton_clock_data[3]*0x1000000);

Any kind of help will be much appreciated
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top