在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
芯片精品文章合集(500篇!) 创芯人才网--重磅上线啦!
查看: 2113|回复: 8

[求助] 求助,PIC汇编程序

[复制链接]
发表于 2014-1-15 09:50:50 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
哪位同学用过PIC单片机,能否帮我看看这个程序是否能够实现流水灯,
仿真或者直接用开发板实验,这里使用PIC16F84。



;*****************************************************************************
;  lights run (0,1,2,...,7,off,7,6,5,...,1,0,off,0,1,2...)
;*****************************************************************************
    LIST P=16F84, R=HEX
    #include p16f84.inc

    flag  equ  H'25'

    org    000h
;*****************************************************************************
;  main code
start
    nop
    bsf    STATUS,5    ;set register file to bank 1
    movlw  0x00    ;set trisb to 0x00(output)
    movwf  TRISB
    bcf    STATUS,5    ;clear bank select bits(default select bank 0)
    movlw  0x01    ;set portb[0]
    movwf  PORTB
    bsf    flag,0    ;set flag[0]
    bcf    STATUS,0    ;clear Carry/Borrow BIT
loop
    btfss  STATUS,0    ;skip if Carry/Borrow BIT set
    goto   loop1
    comf   flag,1    ;complement flag,and place back,
                     ;ie,move the reverse direction
loop1
    btfss  flag,0    ;skip if flag[0] set
    goto   loop2
    rlf    PORTB,0    ;rotate left portb through Carry/Borrow BIT,
    movwf  PORTB      ;and move result to portb
    goto   loop3
loop2
    rrf    PORTB,0    ;rotate right portb through Carry/Borrow BIT,
    movwf  PORTB      ;and move result to portb
loop3
    call   delay
    call   delay
    goto   loop

;*****************************************************************************
;  subroutine delay
delay
    movlw  0x0f    ;set H'20' to 0xff
    movwf  H'20'
lp0
    movlw  0x0f    ;set H'21' to 0xff
    movwf  H'21'
lp1
    decfsz H'21',1    ;decrement H'21',skip if 0,result place back
    goto lp1
    decfsz H'20',1    ;decrement H'20',skip if 0,result place back
    goto lp0
    return

;*****************************************************************************
;  end
    end
发表于 2014-1-15 13:55:41 | 显示全部楼层
汇编比较艰涩...要是c语言的话比较好些.....
 楼主| 发表于 2014-1-15 16:40:45 | 显示全部楼层
回复 2# guolehaohao


   你有PIC相关的编程器和烧录器么,用的是哪些工具
发表于 2014-1-15 17:26:18 | 显示全部楼层
PIC的编程器,不是有PIC Kit2 Kit3
 楼主| 发表于 2014-1-15 17:50:28 | 显示全部楼层
回复 4# McuPlayer2013


   我看了淘宝上面的Kit2,kit3好贵,是不是啊?也有别人自己设计的编程器,但是不兼容所有的PIC系列;
也不知道靠谱不?
发表于 2014-1-15 21:56:32 | 显示全部楼层
回复 3# scott_lele


   抱歉,没有用过PIC的单片机.....可能比较偏吧....
 楼主| 发表于 2014-1-16 08:59:49 | 显示全部楼层
回复 6# guolehaohao

没事,我再找找
发表于 2014-1-16 18:22:47 | 显示全部楼层
我转行了,不做这个了,嘿嘿
发表于 2014-3-11 16:30:53 | 显示全部楼层
Simulator is embedded in to MPLAB IDE. If you want procedure then similar is available on www.blinkthatled.com look for PIC 32 page
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /2 下一条

小黑屋| 手机版| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-9-21 11:18 , Processed in 0.047241 second(s), 9 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表