123.rar

  • linhuanlinhuan
    了解作者
  • DOS
    开发工具
  • 5KB
    文件大小
  • rar
    文件格式
  • 1
    收藏次数
  • 1 积分
    下载积分
  • 1
    下载次数
  • 2017-07-18 23:39
    上传日期
一起学习,PIC12C508509的例程 用PIC12C508509 控制一个步进电机源程序
123.rar
  • PIC12C508509
  • 用PIC12C508A 控制模型源程序.txt
    13KB
  • 用PIC12C509 控制LED.txt
    6.2KB
  • 用PIC12C508509 控制一个步进电机源程序.txt
    2.7KB
内容介绍
; Description: Receive IR Remote control NEC code list p=12C508A, f=INHX8M, r=DEC, b=8, C=80 __config (_MCLRE_OFF & _CP_ON & _WDT_OFF & _IntRC_OSC) __idlocs H'0001' INDF equ 0x00 TMR0 equ 0x01 PCL equ 0x02 STATUS equ 0x03 FSR equ 0x04 OSCCAL equ 0x05 GPIO equ 0x06 Bit7 equ 0x07 Bit6 equ 0x06 Bit5 equ 0x05 Bit4 equ 0x04 Bit3 equ 0x03 Bit2 equ 0x02 Bit1 equ 0x01 Bit0 equ 0x00 W equ 0x00 F equ 0x01 ; STATUS Register GPWUF equ Bit7 PA0 equ Bit5 NOT_TO equ Bit4 NOT_PD equ Bit3 Z equ Bit2 DC equ Bit1 C equ Bit0 ; GPIO Register bIRDataIn equ Bit0 bSystemPowerOut0 equ Bit1 ; Configuration Bits _MCLRE_ON equ 0x0fff _MCLRE_OFF equ 0x0fef _CP_ON equ 0x0ff7 _CP_OFF equ 0x0fff _WDT_ON equ 0x0fff _WDT_OFF equ 0x0ffb _LP_OSC equ 0x0ffc _XT_OSC equ 0x0ffd _IntRC_OSC equ 0x0ffe _ExtRC_OSC equ 0x0fff ; Macro Definition PowerDownSystem MACRO bcf GPIO, bSystemPowerOut0 ENDM PowerUpSystem MACRO bsf GPIO, bSystemPowerOut0 ENDM ; General Purpose Register DelayCounter1 equ 0x07 DelayCounter2 equ 0x08 AddrCode equ 0x10 AddrCodeNot equ 0x11 DataCode equ 0x12 DataCodeNot equ 0x13 Result equ 0x14 PowerState equ 0x15 ButtonTemp equ 0x16 Bit equ 0x17 GetBitCounter equ 0x18 GetBitCountLo equ 0x19 GetBitCountHi equ 0x1A PausecountLo equ 0x1B PausecountHi equ 0x1C errorflag equ 0x1D ; Constant Definition cPowerOn equ 0xFF cPowerOff equ 0x00 cPowerHi equ 0x82 cPowerLo equ 0x7D cAddressHi equ 0xF0 cAddressLo equ 0x0F ;============================================================================== org 0000h movwf OSCCAL goto main ;------------------------------------------------------------------------------ ; Function: pDelay1ms ; Overview: This is a very accurate 1ms delay for a 4MHz clock. ;------------------------------------------------------------------------------ pDelay1ms: movlw .198 movwf DelayCounter1 nop nop tagDelay1ms_01: nop nop decfsz DelayCounter1, F goto tagDelay1ms_01 retlw 0x00 ;------------------------------------------------------------------------------ ; Function: pDelay250ms ; Overview: ;------------------------------------------------------------------------------ pDelay250ms: movlw .250 movwf DelayCounter2 tagDelay250ms_01: call pDelay1ms decfsz DelayCounter2, F goto tagDelay250ms_01 retlw 0x00 ;------------------------------------------------------------------------------ ; Function: pGetBit ; Overview: ;------------------------------------------------------------------------------ pGetBit: tagBitStart: clrf errorflag clrf GetBitCountLo clrf GetBitCountHi tagBitWait: btfss GPIO, bIRDataIn goto tagBitWait tagBitLoop: incfsz GetBitCountLo, F goto tagBitNext incf GetBitCountHi, F movlw .3 subwf GetBitCountHi,W btfsc STATUS,C goto errorret tagBitNext: btfsc GPIO, bIRDataIn goto tagBitLoop movlw .1 subwf GetBitCountHi, W btfsc STATUS, Z goto tagBitIsOne tagBitIsZero: movlw 0x00 movwf Bit goto tagBitDone tagBitIsOne: movlw 0xff movwf Bit goto tagBitDone tagBitDone: retlw 0x00 errorret: bsf errorflag,Bit0 retlw 0x00 ;------------------------------------------------------------------------------ ;============================================================================== ; Program Main Entry. ;============================================================================== main: movlw B'11000111' option movlw B'11111101' tris GPIO ;PowerUpSystem movlw B'11111111' movwf GPIO movlw cPowerOn movwf PowerState initial: clrf AddrCode clrf AddrCodeNot clrf DataCode clrf DataCodeNot doIrCheck: btfsc GPIO, bIRDataIn goto doIrCheck ;================================================ ;call pGetBit leaderWait: btfss GPIO, bIRDataIn goto leaderWait call pGetBit pauseWait: ;btfsc GPIO, bIRDataIn ;goto pauseWait movf GetBitCountLo,W movwf PausecountLo movf GetBitCountHi,W movwf PausecountHi movlw 0x02 subwf PausecountHi,W btfss STATUS,Z ;btfss PausecountHi,Bit1 goto doIrCheck ;btfsc GPIO,bIRDataIn ;goto ;================================================ AddrBit0: call pGetBit btfsc errorflag,Bit0 goto doIrCheck btfss Bit, Bit7 goto AddrBit0Zero AddrBit0One: bsf AddrCode, Bit0 goto AddrBit1 AddrBit0Zero: bcf AddrCode, Bit0 ;------------------------------------------------ AddrBit1: call pGetBit btfsc errorflag,Bit0 goto doIrCheck btfss Bit, Bit7 goto AddrBit1Zero AddrBit1One: bsf AddrCode, Bit1 goto AddrBit2 AddrBit1Zero: bcf AddrCode, Bit1 ;------------------------------------------------ AddrBit2: call pGetBit btfsc errorflag,Bit0 goto doIrCheck btfss Bit, Bit7 goto AddrBit2Zero AddrBit2One: bsf AddrCode, Bit2 goto AddrBit3 AddrBit2Zero: bcf AddrCode, Bit2 ;------------------------------------------------ AddrBit3: call pGetBit btfsc errorflag,Bit0 goto doIrCheck btfss Bit, Bit7 goto AddrBit3Zero AddrBit3One: bsf AddrCode, Bit3 goto AddrBit4 AddrBit3Zero: bcf AddrCode, Bit3 ;------------------------------------------------ AddrBit4: call pGetBit btfsc errorflag,Bit0 goto doIrCheck btfss Bit, Bit7 goto AddrBit4Zero AddrBit4One: bsf AddrCode, Bit4 goto AddrBit5 AddrBit4Zero: bcf AddrCode, Bit4 ;------------------------------------------------ AddrBit5: call pGetBit btfsc errorflag,Bit0 goto doIrCheck btfss Bit, Bit7 goto AddrBit5Zero AddrBit5One: bsf AddrCode, Bit5 goto AddrBit6 AddrBit5Zero: bcf AddrCode, Bit5 ;------------------------------------------------ AddrBit6: call pGetBit btfsc errorflag,Bit0 goto doIrCheck btfss Bit, Bit7 goto AddrBit6Zero AddrBit6One: bsf AddrCode, Bit6 goto AddrBit7 AddrBit6Zero: bcf AddrCode, Bit6 ;------------------------------------------------ AddrBit7: call pGetBit btfsc errorflag,Bit0 goto doIrCheck btfss Bit, Bit7 goto AddrBit7Zero AddrBit7One: bsf AddrCode, Bit7 goto AddrNotBit0 AddrBit7Zero: bcf AddrCode, Bit7 ;++++++++++++++++++++++++++++++++++++++++++++++++ AddrNotBit0: call pGetBit btfsc errorflag,Bit0 goto doIrCheck btfss Bit, Bit7 goto AddrNotBit0Zero AddrNotBit0One: bsf AddrCodeNot, Bit0 goto AddrNotBit1 AddrNotBit0Zero: bcf AddrCodeNot, Bit0 ;------------------------------------------------ AddrNotBit1: call pGetBit btfsc errorflag,Bit0 goto doIrCheck btfss Bit, Bit7 goto AddrNotBit1Zero AddrNotBit1One: bsf AddrCodeNot, Bit1 goto AddrNotBit2 AddrNotBit1Zero: bcf AddrCodeNot, Bit1 ;------------------------------------------------ AddrNotBit2: call pGetBit btfsc errorflag,Bit0 goto doIrCheck btfss Bit, Bit7 goto AddrNotBit2Zero AddrNotBit2One: bsf AddrCodeNot, Bit2 goto AddrNotBit3 AddrNotBit2Zero: bcf AddrCodeNot, Bit2 ;------------------------------------------------ AddrNotBit3: call pGetBit btfsc errorflag,Bit0 goto doIrCheck btfss Bit, Bit7 goto AddrNotBit3Zero AddrNotBit3One: bsf AddrCodeNot, Bit3 goto AddrNotBit4 AddrNotBit3Zero: bcf AddrCodeNot, Bit3 ;------------------------------------------------ AddrNotBit4: call pGetBit btfsc errorflag,Bit0 goto doIrCheck btfss Bit, Bit7 goto AddrNotBit4Zero AddrNotBit4One: bsf AddrCodeNot, Bit4 goto AddrNotBit5 AddrNotBit4Zero: bcf AddrCodeNot, Bit4 ;------------------------------------------------ AddrNotBit5: call pGetBit btfsc errorflag,Bit0 goto doIrCheck btfss Bit, Bit7 goto AddrNotBit5Zero AddrNotBit5One: bsf AddrCodeNot, Bit5 goto AddrNotBit6 AddrNotBit5Zero: bcf AddrCodeNot, Bit5 ;------------------------------------------------ AddrNotBit6: call pGetBit btfsc errorflag,Bit0 goto doIrCheck btfss Bit, Bit7 goto AddrNotBit6Zero AddrNotBit6One: bsf AddrCodeNot, Bit6 goto AddrNotBit7 AddrNotBit6Zero: bcf AddrCodeNot, Bit6 ;------------------------------------------------ AddrNotBit7: call pGetBit btfsc errorflag,Bit0 goto doIrCheck btfss Bit, Bit7 goto AddrNotBit7Zero AddrNotBit7One: bsf AddrCodeNot,
评论
    相关推荐
    • PIC12C508.rar
      PIC单片机的学习,12C508主要是8个引脚的MCU。
    • PIC12C508.rar
      8引脚单片机,pic12c508实现的简单程序,适合初学者。欢迎加入嵌入式开发QQ交流群:221694313
    • pic12c508-ex.rar
      Night Light use by PIC12c508 with C language, including circuit. Anyone can do it yourself.
    • pic12c508-PWM.rar
      循环点亮灯,在按键按下的时候,会根据不同的按键亮不同的灯。
    • pic12c508luces.rar
      Programing in C microchip pic 12f508 to serial ligth game
    • PIC12C508.rar
      pic12c508的应用,实际电路图的连接,包括LED灯的控制,串行通信
    • pic12c508-PWM.rar
      循环点亮灯,在按键按下的时候,会根据不同的按键亮不同的灯。
    • PIC12C508A_ASM.zip
      PIC12C508A单片机控制模型源程序
    • PIC12C508单片机控制灯光源程序
      以上程序使用PIC12C508单片机,内部4MHZ时钟,4脚输入50HZ脉冲信号,7,6,3脚(GP0,GP1,GP4端口)为输出口。其中渐变部分是让灯慢慢的变亮(或灭)。不知道以上程序有没错误,有错误之处请大家多多给意见
    • pic12c508 单片机程序
      PIC12c508单片机程序,官方编译器工程,闪灯程序。单片机闪灯程序,标准手电筒程序。