文档详情

PIC控制步进电机.doc

发布:2018-10-13约6.21千字共5页下载文档
文本预览下载声明
PIC控制步进电机完整资料 [日期:2008-06-16 ] [来源:net 作者:佚名] [字体:大 中 小] (投递新闻) 点击放大 点击放大 点击放大 #2 F84程序, ;******************************************************** ; ; Stepper Motor controller ; ; Author : Seiichi Inoue ;******************************************************** list p=pic16f84a include p16f84a.inc __config _hs_osc _wdt_off _pwrte_on _cp_off errorlevel -302 ;Eliminate bank warning ;**************** Label Definition ******************** cblock h0c mode ;Operation mode ;0=stop 1=right 2=left count1 ;Wait counter count2 ;Wait counter(for 1msec) endc rb0 equ 0 ;RB0 of PORTB rb1 equ 1 ;RB1 of PORTB rb2 equ 2 ;RB2 of PORTB rb5 equ 5 ;RB5 of PORTB rb7 equ 7 ;RB7 of PORTB ;**************** Program Start *********************** org 0 ;Reset Vector goto init org 4 ;Interrupt Vector clrf intcon ;Clear Interruption reg ;**************** Initial Process ********************* init bsf status,rp0 ;Change to Bank1 clrf trisa ;Set PORTA all OUT movlw ;RB0,1,2.5=IN RB7=OUT movwf trisb ;Set PORTB movlw ;RBPU=1 Pull up not use movwf option_reg ;Set OPTION_REG bcf status,rp0 ;Change to Bank0 clrf mode ;Set mode = stop clrf count1 ;Clear counter clrf count2 ;Clear counter movlw ;Set PORTA initial value movwf porta ;Write PORTA bsf portb,rb7 ;Set RB7 = 1 btfsc portb,rb5 ;RB5 = 0
显示全部
相似文档