pic10f200的一段玩具代码

 title "PIC10F202 counting program"
 list p=10f202
 #include <p10f202.inc> ;

 __CONFIG _CP_OFF & _MCLRE_OFF & _WDT_OFF & _IntRC_OSC

cpt1 equ 0x08
cpt2 equ 0x09
cpt3 equ 0x0A

 org 00h ;reset vector
 andlw 0xfe
 movwf OSCCAL
 clrf GPIO
 movlw 0x0b
 tris GPIO
 movlw 0xc0
 option

IncCount
 call Delay1s
 btfsc GPIO,2
 goto next
 bsf GPIO,2
 goto IncCount
next
 bcf GPIO,2
 goto IncCount ;loop

;------------------------------------------------
Delay1ms   ;2us for CALL
 movlw 0xF9
 movwf cpt1 ;2us
etiq2
 nop    ;loop=4us*(0xF9=249)=996us
 decfsz cpt1,F
 goto etiq2
 retlw 0x00

;------------------------------------------------
Delay1s
 movlw 0x0A
 movwf cpt3
etiq4
 movlw 0x64
 movwf cpt2
etiq3
 call Delay1ms
 decfsz cpt2,F
 goto etiq3
 decfsz cpt3,F
 goto etiq4
 retlw 0x00

 end

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值