打印

有人研究过PIC10F做的电容传感器吗

[复制链接]
1785|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
hbsun2007|  楼主 | 2009-6-30 15:19 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
MICROCHIP提供的汇编源程序我不太理解,有人能帮帮忙吗?


        movf    tmr0,w          ; high byte of value is stored in tmr0
        movwf   freqhi          ; low value is still in the prescaler
                                ; freqhi=tmr0

; To get the value from the prescaler (which is not directly readable),
; the clock source for tmr0 is changed to Fosc/4.
; Next the value of tmr0 is observed. The time is takes for the next
; increment is an indication of the value of the prescaler.

        movlw   b'11010111'     ; change clock source to Fosc/4
        option                     ;内部指令周期时钟 FOSC/4上的电平变化

measureprescaler
   incf    freqlo          ; was initialised to 255 and set to 0 here                    freqlo+1=0
   movf    tmr0,w          ; get the current value of tmr0                              w=tmr0
   xorwf   freqhi,w        ; compare it with the original value of   tmr0                w与freqhi作逻辑异或运算

   btfsc   status,z        ; did tmr0 increment?                    ; 测试status中的位z,为0 则跳过
        ;if(tmr0!=freqhi)
        goto    measureprescaler ; no, loop and increment freqlo

8位的定时器,他的那个计数器的高低字节是怎么算的
沙发
yewuyi| | 2009-6-30 15:58 | 只看该作者

电容传感器?

是测量电容值把?!

使用特权

评论回复
板凳
hbsun2007|  楼主 | 2009-6-30 19:49 | 只看该作者

差不多吧

测量频率来达到测量电容的效果,具体的MICROCHIP官方网站上有解决方案,但我对于它的汇编语言不是很了解

使用特权

评论回复
地板
xieyuanbin| | 2009-7-1 09:29 | 只看该作者

你的程序断章取义

 movf    tmr0,w          ; get the current value of tmr0                              w=tmr0
   xorwf   freqhi,w        ; compare it with the original value of   tmr0                w与freqhi作逻辑异或运算
这两句,与下列程序等价:
 movf tmr0,w
 subwf freqhi,w

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

25

主题

87

帖子

0

粉丝