Re: Delay time!!!!!!!
First, determine the length of time per machine cycle. That's the internal instruction clock. For PIC, a machine cycle is equal to your Oscillator speed divided by 4. So, if you have a 4MHz oscillator, your internal PIC speed is 4MHz/4 = 1MHz. That's the frequency. The period, or length of time, of each machine cycle then is 1/1MHz = 1 microsecond.
Each ASM instruction is 1 machine cycle. A GOTO, SKIP, and RETURN are 2 machine cycles each. For illustration, the following:
Code:
movlw D'251'; // 1 cycle
movwf CounterA; // 1 cycle
loop decfsz CounterA,1; // 1 cycle (2 cycles for Skip when 0)
goto loop; // 2 cycles
In this example, 2 machine cycles for loading CounterA + 251 * 3 cycles for the Loop = 755 cycles = 755uS.
Hope that helps you do the rest of the calculation. Just follow the path of the code and start counting cycles.
In your code above, you need to put one loop inside of the other loop to get multiple 755us delays. Right now, you only have 2 separate delay loops in sequence and then it's done. It can't be 10mS like that. The following will give you 13 * 755us + some extra cycles:
Code:
movlw D'13'
movwf CounterB
outerloop:
movlw D'251'
movwf CounterA
innerloop:
decfsz CounterA,1
goto innerloop
decfsz CounterB,1
goto outerloop
return