Hi there, I have a development board around the aduc832BS processor and use Keil uVision2 ver2.40 for software development. I tried to implement the 1wire routines for DS18B20 (which i conected at P3.4) but it seems that i have a timing problem.it all starts from the delay function.I use PLLCON=0x051(fcore=8.388608mhz) below is an example of timing delay for DS5000 (8051 compatible) microcontroller with an 11.059MHz clock. //Calling the routine takes about 24us,and //then each count takes another 16us. void delay(int useconds) { int s; for (s=0; s<useconds;s++); } I also know that ADuC832 Machine Cycle Time is nominally 12/Core_CLK. Could you tell me please how can i calculate the timings for the DELAY() (the Machine Cycles required for them) based on the aduc832. (ex. calling time for the delay() routine,calling time for each count in this routine). For the DS5000 the reset routine is: (Reset is 480us, so delay value is (480-24)/16 = 28.5 - we use 29.Presence checked another 70us later, so delay is (70-24)/16 = 2.875 - we use 3). unsigned char ow_reset(void) { unsigned char presence; DQ = 0; //pull DQ line low delay(29); // leave it low for 480us DQ = 1; // allow line to return high delay(3); // wait for presence presence = DQ; // get presence signal delay(25); // wait for end of timeslot return(presence); // presence signal returned } // 0=presence, 1 = no part Thank you in advance for helping me out.
"I wonder,is really impossible to estimate the calling time for this delay() and for each count?" Nobody said it was impossible. But the only way to do it is to know the precise machine instructions - and you cannot guarantee precisely what machine instructions any compiler will generate. Sure, you can compile it and then examine the generated code and compute the timings for that particular compilation; but you have no guarantee whatever that you will get exactly the same code generated next time - especially if you use a different compiler and/or version, and/or fiddle with the compiler options.