Hi Nigel,
I'm converting the ASM code in to mikroBasic code and have stumbled across a timing question.
I am looking at the mtx_bitdel routine, in tut12_5Ta.asm, that you modified and I am figuring out the timing of this. I am a bit confused as to the exact figure here. You indicated that you need a 105:mu:Sec delay, however my calculations are different than what is coded.
Here are my calculations:
20Mhz clock means 0.2:mu:Sec per instruction (1/20 * 4)
Checking the Datasheet I see that the all the instructions in the mtx_bitdel routine takes 1 clock cycle except the return and goto statements which take 2.
Therefore the loop around the 68 takes 68 * 3 = 204 clock cycles.
The outer loop around the 3 takes 3 * 3 = 9 clock cycles.
So there looping takes 9 * 204 = 1,836 clock cyles.
Add on to this the intial statements of 4 and the return statement of 2 gives a grand total of 1,842 clock cyles to perform the mtx_bitdel routine.
So the time to do this routine is 1,842 * 0.2 = 368.4:mu:Sec, not the 105:mu:Sec indicated in the comments.
Are my calculations correct? Its just I need to rejig them for my 8Mhz clock and was wondering if I had things right.
Thanks,
Craig