>> Bernd Grunwald wrote: >> >> >Has anyone written some code reading the temperature from an DS1821 into an >> >PIC and can help me a little bit with implementing that? Or is there some > code >> >somewhere on the Internet? ... >I just found it and it seems to be exactly what I need. >Thanx! No problem. >> >I want to implement my project on the 16F84 4MHz. I have to wait in some >> >condition for about 3 minutes and also have to read the temperature (DS1821) >> >meanwhile. But I have only one timer in the PIC and that seems to be not so >> >simple. Has anyone an easy method to measure 3 minutes (+-10 sec) without > using >> >the timer and working with the pic meanwhile. The IRQ pin PB0 would be >> >available, but I don't want to use much more external components ... >> >> Why don't you use the Watchdog timer? If you have to use the Prescaler for > >If I understood the Datasheet correct, the Watchdog timer resets the PIC, if it >is not in sleep mode?!? Yes. What I was thinking was setting up a known pattern in the file registers and when you are executing at the reset address check the file registers for the known pattern, if they are there then jump to reading the temperature and sending it off. If the pattern isn't there, then set up your application. >> something else, you could use a 16 bit timer to count to 10,000 (which is >> the number of 18 msec intervals in 3 minutes). > >Do You mean an external timer? No, I mean two 8 bit counters set up as a Timer. After confirming that the power-up pattern is the same as what you expect, the code would be: counter++; // Increment the 16 Bit Counter if ( counter < 10000 ) sleep; // Go to Sleep if three Minutes haven't elapsed else { // Put in Temperature Read Code Here } /* endif */ Good luck, myke "One must invoke enough raw truth to punch a hole in the world" - Darl Af