> Hello everybody, > I am having deficalty in getting the right dely to the clock i am using for my pic16f877. which i am using 20MHz clock. I have calculated a 1msec as follows: The problem is: it takes 4 cycles of the 20MHz clock for each instruction (and 8 for branches and skips 'taken'). So your results are off by a factor of 3. (note: I didn't actually verify your code, just your comments). Bob Ammerman RAm Systems (contract development of high performance, high function, low-level software) > I have a clock of 20MHz that meens 50nsec > then I have three instructions for each function so what i did is > 50nsec X 3inst X (how many time to be multiplied (n))= 1msec > so, > n = (1m X 20MHz) / 3inst = 6666.66666 > then, > I devided that number by 100 to split it into two equations, so I got 67 and 100. > > the following is my iomplemented function, however, i am not getting the right delay. I am geting larger delay > > > > Wait1ms > movlw .67 > movwf temp11 > Wait1msB1 > movlw .100 > movwf temp12 > Wait1msB2 > decfsz temp12,1 ; this is one instruction > goto Wait1msB2 ; this is two instructions which make 3 total > decfsz temp11,1 ; the same here > goto Wait1msB1 > return > > can any body help > Thank you > > regards, > Paul > > > -------------------------------------------------------------------------- ------ > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. > > > -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics > -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics