完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
有人能帮助我理解为什么这个延迟环产生9MS延迟吗?我怎么计算这个?我理解它产生9000个周期,每个1us,但是我不明白为什么。decfsz=2cyclesgoto=2个周期,但是9000的计算是什么?谢谢你的帮助....Delay_setup;Delay=0.009秒;Clock频率=4MHz;实际延迟=0.009秒=9000周期;Error=0%cblock;constantsd1d2endc块;8998cyclesmovlw 0x07movwf d1movlw 0x08movwf d2Delaydecfsz d1,fgoto$+2decfszd2,fgoto Delay;2cyclesgogoto$+1.
以上来自于百度翻译 以下为原文 Can someone help me understand why this delay loop generate 9ms delay? how can i calculate this? i understand that it generates 9000 cyclels of 1us each, but i cant see why. decfsz = 2 cycles goto = 2 cycles but what is the calculation for 9000? Thanks for the help.... Delay_setup ; Delay = 0.009 seconds ; Clock frequency = 4 MHz ; Actual delay = 0.009 seconds = 9000 cycles ; Error = 0 % cblock ;block of constants d1 d2 endc ;8998 cycles movlw 0x07 movwf d1 movlw 0x08 movwf d2 Delay decfsz d1, f goto $+2 decfsz d2, f goto Delay ;2 cycles goto $+1 return |
|
相关推荐
7个回答
|
|
注意:DECFSZ是一个循环,除非它必须跳过两个循环。它将执行内循环(不递减d2),7次,对于(6*5)+(1*6)循环=36个循环,它将运行内循环256次,并且对于7*((255*5)+(1*6)==重复另外7次8967 Cys8967+36=9003个循环,作者说8998,所以也许我错过了几个周期。
以上来自于百度翻译 以下为原文 A little easier to read: Delay: decfsz d1, f ;2 goto skipover ;2 decfsz d2, f ;2 skipover: goto Delay ;2 Note: DECFSZ is one cycle, except when it has to do the skip it is two. That will execute the inner loop (not decrementing d2), seven times, for (6*5)+(1*6) cycles = 36 cycles then it will run the inner loop 256 times, and repeat that another 7 times for 7*((255*5) + (1*6)) = 8967 cycles 8967+36 = 9003 cycles The author says 8998, so maybe I misses a couple of cycles somewhere. |
|
|
|
实际上,调用该例程需要9004个指令周期(Tcy)。是:2+4+〔5×6+2〕+ [ [(5×255+2+3)] * 7+2 ]+4=4
以上来自于百度翻译 以下为原文 Actually, calling that routine will take 9004 instruction cycles (Tcy). Here's the breakdown:
2 + 4 + [5*6 + 2] + [(5*255 + 2 + 3)*7 + 2] + 4 = 9004 Tcy |
|
|
|
谢谢你的帮助!为什么我们使用DEFSFZ D1,F,而不是DEFSFZ D1,1?2、这255个是从哪里来的????3、在调试时,我能看到D1和D2的值吗?
以上来自于百度翻译 以下为原文 Thanks for the help! Just another two small clarifications 1.Why we use decfsz d1,f and not decfsz d1,1? 2.Where the 255 came from??? 3.Can I see the values of d1 and d2 while debugging? |
|
|
|
“f”清楚地表明目的地是FSR,而不是W寄存器的“w”。变量从00->FF->00一直递减,即256个循环。在最后一个循环中,将执行跳过,对于其他255(256-1),将不执行跳过。
以上来自于百度翻译 以下为原文 "f" clearly indicates that the destination is the FSR, rather than "w" for the W register. The variable decrements all the way from 00 -> FF -> 00 which is 256 loops On the final loop, the skip will be performed, for the other 255 (256-1), it will not be performed. |
|
|
|
|
|
|
|
谢谢大家的帮助!如何在调试时看到D1和D2的值?
以上来自于百度翻译 以下为原文 thank you all for your help! how can i see the values of d1 and d2 while debuging? |
|
|
|
使用调试器中的“监视”窗口,并从下拉列表中选择这两个变量。
以上来自于百度翻译 以下为原文 Use the "Watch" window in the debugger, and select those two variables from the dropdown list. |
|
|
|
只有小组成员才能发言,加入小组>>
5244 浏览 9 评论
2035 浏览 8 评论
1955 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3209 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2260 浏览 5 评论
779浏览 1评论
672浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
598浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
682浏览 0评论
579浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-25 02:22 , Processed in 1.491610 second(s), Total 90, Slave 74 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号