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.

[SOLVED] Ds1820+PIC18f452+Hyperterminal----- Problem

Status
Not open for further replies.

abdul991

Junior Member level 1
Junior Member level 1
Joined
Feb 8, 2013
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,402
I'm using mplab -pickit 2 for programing single Ds1820+PIC18f452+Hyperterminal. I'm new to this 1-wire concept.
The problem is i'm unable to receive the output-low presence pulse after i send reset pulse for more than 480usec to the ds1820

This is my code. Please help. i'm doing my engg. project

Code:
while(1)
   { 
    
    DS1820_DelayUs(10000);
       
    serialSend1(resetTx());serial Transmit
           
   }

bool input_func(void)
{
    TRISBbits.TRISB3 = 1;     
    return PORTBbits.RB3;
}

bool resetTx()
{
   bool bPresPulse;
   
   TRISBbits.TRISB3 = 0;
   PORTBbits.RB3 = 0                 
   DS1820_DelayUs(500);
   serialSendRst(input_func());   // serial Transmit 
   DS1820_DelayUs(40);

   /* get presence pulse */
   
   DS1820_DelayUs(100);
   bPresPulse = input_func();
   
   return bPresPulse;
}


// 12Mhz clock = > ( 1/12M)secs  per clock cycle.
// 1 inst = 4 clock cycle = 4*1/12M = 0.333 usec

// 1usec delay = 1/.333 = 3


void DS1820_DelayUs(long delayUs)
{
int i,j;
for (i=0;i<delayUs;i++)
for (j=0;j<3;j++);
}
 

Code:
i've somehow understood the problem is with the delay......

so i altered the code but the result is...... pr= 1 pr= 1 pr= 1..... i should have got pr=1 pr=0.... continuously... at Hyperterminal


Code:
 #define input(pin)   input_func()  // <----this func is defined in previous post
#define output_low(pin)     TRISBbits.TRISB3 = 0;PORTBbits.RB3 = 0
main(){
while(1)

    DS1820_DelayMs(1000);
    serialSendRst(input(pin));    
    DS1820_DelayMs(1000);
    serialSendRst(resetTx());
          
   }
}
              
/***************************************************/

/*

The bus master transmits (TX) a reset pulse (a low signal
for a minimum of 480 usec). The bus master then
releases the line and goes into a receive mode (RX).
The 1–Wire bus is pulled to a high state via the 5K
pull–up resistor . After detecting the rising edge on the
I/O pin, the DS1820 waits 15–60 usec and then transmits
the presence pulse (a low signal for 60–240 usec).

*/

bool resetTx()
{
   bool bPresPulse;
   
   output_low(pin);                 
   DS1820_DelayUs(24);    //24*20usec = 480
 
   bPresPulse = input(pin);
                             // uses 15 + serTx baudrate delay
   DS1820_DelayUs(5);
   /* get presence pulse */
   
   bPresPulse = input(pin);
   
   return bPresPulse;

}

/****************************************************/

// 12Mhz = > ( 1/12M) sec per clock cycle.
// 1 inst = 4 clock cycle = 4*1/12M = 0.333 usec

// 1usec delay = 1/.333 = 3

// As per Modified-Delay :- 1 delayUs =  6.66usec *3 Inst  =  20 useconds.

void DS1820_DelayUs(long delayUs)
{
int i,j;
for (i=0;i<delayUs;i++)
for (j=0;j<3;j++);
}

/****************************************************/
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top