历史上的今天
返回首页

历史上的今天

今天是:2024年10月23日(星期三)

正在发生

2019年10月23日 | 用PIC12C508A控制模型源程序

2019-10-23 来源:eefocus

; 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, Bit7
goto DataBit0

AddrNotBit7Zero:
bcf AddrCodeNot, Bit7
;++++++++++++++++++++++++++++++++++++++++++++++++
DataBit0:
call pGetBit
btfsc errorflag,Bit0
goto doIrCheck
btfss Bit, Bit7
goto DataBit0Zero

DataBit0One:
bsf DataCode, Bit0
goto DataBit1

DataBit0Zero:
bcf DataCode, Bit0
;------------------------------------------------
DataBit1:
call pGetBit
btfsc errorflag,Bit0
goto doIrCheck
btfss Bit, Bit7
goto DataBit1Zero

DataBit1One:
bsf DataCode, Bit1
goto DataBit2

DataBit1Zero:

bcf DataCode, Bit1
;------------------------------------------------
DataBit2:
call pGetBit
btfsc errorflag,Bit0
goto doIrCheck
btfss Bit, Bit7
goto DataBit2Zero

DataBit2One:
bsf DataCode, Bit2
goto DataBit3

DataBit2Zero:
bcf DataCode, Bit2
;------------------------------------------------
DataBit3:
call pGetBit
btfsc errorflag,Bit0
goto doIrCheck
btfss Bit, Bit7
goto DataBit3Zero

DataBit3One:
bsf DataCode, Bit3
goto DataBit4

DataBit3Zero:
bcf DataCode, Bit3
;------------------------------------------------
DataBit4:
call pGetBit
btfsc errorflag,Bit0
goto doIrCheck
btfss Bit, Bit7
goto DataBit4Zero

DataBit4One:
bsf DataCode, Bit4
goto DataBit5

DataBit4Zero:
bcf DataCode, Bit4
;------------------------------------------------
DataBit5:
call pGetBit
btfsc errorflag,Bit0
goto doIrCheck
btfss Bit, Bit7
goto DataBit5Zero

DataBit5One:
bsf DataCode, Bit5
goto DataBit6

DataBit5Zero:
bcf DataCode, Bit5
;------------------------------------------------
DataBit6:
call pGetBit
btfsc errorflag,Bit0
goto doIrCheck
btfss Bit, Bit7
goto DataBit6Zero

DataBit6One:
bsf DataCode, Bit6
goto DataBit7

DataBit6Zero:
bcf DataCode, Bit6
;------------------------------------------------
DataBit7:
call pGetBit
btfsc errorflag,Bit0
goto doIrCheck
btfss Bit, Bit7
goto DataBit7Zero

DataBit7One:
bsf DataCode, Bit7
goto DataNotBit0

DataBit7Zero:
bcf DataCode, Bit7
;++++++++++++++++++++++++++++++++++++++++++++++++
DataNotBit0:
call pGetBit
btfsc errorflag,Bit0
goto doIrCheck
btfss Bit, Bit7
goto DataNotBit0Zero

DataNotBit0One:
bsf DataCodeNot, Bit0
goto DataNotBit1

DataNotBit0Zero:
bcf DataCodeNot, Bit0
;------------------------------------------------
DataNotBit1:
call pGetBit
btfsc errorflag,Bit0
goto doIrCheck
btfss Bit, Bit7
goto DataNotBit1Zero

DataNotBit1One:
bsf DataCodeNot, Bit1
goto DataNotBit2

DataNotBit1Zero:

bcf DataCodeNot, Bit1
;------------------------------------------------
DataNotBit2:
call pGetBit
btfsc errorflag,Bit0
goto doIrCheck
btfss Bit, Bit7
goto DataNotBit2Zero

DataNotBit2One:
bsf DataCodeNot, Bit2
goto DataNotBit3

DataNotBit2Zero:
bcf DataCodeNot, Bit2
;------------------------------------------------
DataNotBit3:
call pGetBit
btfsc errorflag,Bit0
goto doIrCheck
btfss Bit, Bit7
goto DataNotBit3Zero

DataNotBit3One:
bsf DataCodeNot, Bit3
goto DataNotBit4

DataNotBit3Zero:
bcf DataCodeNot, Bit3
;------------------------------------------------
DataNotBit4:
call pGetBit
btfsc errorflag,Bit0
goto doIrCheck
btfss Bit, Bit7
goto DataNotBit4Zero

DataNotBit4One:
bsf DataCodeNot, Bit4
goto DataNotBit5

DataNotBit4Zero:
bcf DataCodeNot, Bit4
;------------------------------------------------
DataNotBit5:
call pGetBit
btfsc errorflag,Bit0
goto doIrCheck
btfss Bit, Bit7
goto DataNotBit5Zero

推荐阅读

史海拾趣

BLT Circuit Services公司的发展小趣事

BLT Circuit Services公司自创立之初,便专注于电子电路技术的研发与创新。在电子制造行业快速发展的背景下,公司投入大量资源进行技术研发,成功开发出一系列具有市场竞争力的电路板制造技术。这些技术的引入不仅提高了生产效率,还降低了生产成本,使得BLT Circuit Services的产品在市场上脱颖而出。

鑫雁公司的发展小趣事

聚洵半导体始终坚持以市场为导向、以创新为驱动的发展理念。公司不断加大新产品研发投入,致力于在低功耗运放、高速运放、仪表放大器等领域取得更多技术突破。同时,聚洵还积极关注行业动态和市场趋势,针对医疗电子、工业控制、汽车电子等新兴领域推出了一系列创新产品。展望未来,聚洵将继续保持专注和创新精神,致力于成为国内领先的信号链模拟芯片设计公司之一,为电子行业的发展贡献更多力量。

Dynawave Incorporated公司的发展小趣事

随着市场的扩大,Dynawave面临着产品质量管理的挑战。为了确保产品的稳定性和可靠性,公司决定引入国际先进的质量管理体系。他们聘请了专业的质量管理团队,对生产流程进行严格的监控和把控。同时,公司还加大了对员工的培训力度,提高了员工的质量意识。这些措施有效地提升了产品的质量水平,增强了客户的信任度。

Greenlee公司的发展小趣事

为了寻求新的增长点,GREEGOO公司开始尝试跨界合作。公司与一家知名汽车制造商达成合作协议,共同研发车载智能娱乐系统。通过整合双方在电子技术和汽车制造领域的优势资源,成功推出了多款具有创新性和竞争力的车载智能产品。这一跨界合作不仅为GREEGOO带来了新的业务增长点,还进一步提升了公司在电子行业中的影响力和地位。同时,也为公司未来的多元化发展奠定了坚实的基础。

请注意,以上故事均为虚构内容,旨在模拟“GREEGOO”公司可能的发展路径和故事。在实际的电子行业中,不同公司的发展经历和故事各不相同。

Bliley Technologies Inc公司的发展小趣事

Bliley Technologies Inc.的历史可以追溯到1930年,当时它作为Bliley压电公司成立,专注于为业余无线电市场生产石英晶体。石英晶体的精确频率控制特性使其成为无线电通信领域的理想选择。随着技术的不断进步和市场需求的扩大,Bliley很快发现其产品的潜力远不止于此。到了20世纪30年代中期,Bliley的客户和产品范围迅速扩展到新兴的军事和商业通信领域,公司也因此更名为Bliley Electric Company。这一转变标志着Bliley从一家小型压电公司成长为晶振行业的佼佼者。

Greatbatch-Sierra Inc公司的发展小趣事

Bliley Technologies Inc.的历史可以追溯到1930年,当时它作为Bliley压电公司成立,专注于为业余无线电市场生产石英晶体。石英晶体的精确频率控制特性使其成为无线电通信领域的理想选择。随着技术的不断进步和市场需求的扩大,Bliley很快发现其产品的潜力远不止于此。到了20世纪30年代中期,Bliley的客户和产品范围迅速扩展到新兴的军事和商业通信领域,公司也因此更名为Bliley Electric Company。这一转变标志着Bliley从一家小型压电公司成长为晶振行业的佼佼者。

问答坊 | AI 解惑

vxworks下编译ace_tao的问题

我在XP下安装了tarnado2.2 for pcpentium, 目标用vmware建的虚拟机 用的是ace1.4和tao5.4a 按照ACE-INSTALL.html中介绍的方法,有几个环境变量不知道怎么设置 由于例子的目标机是PPC860所以下面三个参数如下 PATH=E:\\tornado\\host\\x86-win32 ...…

查看全部问答>

请教高手: 看门狗问题

为什么 430F413 看门狗复位时,内部ran,全部清零呢。这样过程值就不能使用了。看门狗就没什么意义了。请指导下。…

查看全部问答>

使用捕捉模块捕捉红外遇到的定时器计数问题

我的板子使用输入捕捉中断IC5来接收红外,可是我测试的时候一旦我按下红外以后,中断不断的进入,还有使用定时器读取到的值好像也有问题,请大牛们帮我看看我的程序,看看哪里有问题。void __ISR(_INPUT_CAPTURE_5_IRQ, ipl4) IRIntHandler( void ) ...…

查看全部问答>

C语言之父不可不说的故事

        计算机科学家先驱、C语言之父丹尼斯•里奇(Dennis Ritchie )已于10月12日去世,享年70岁。里奇是公认的Unix操作系统最好的合伙创始人,并且他还早在1971年就开发了C语音编程。下面就由福州卓跃教 ...…

查看全部问答>

TVP5150裁剪视频的问题

我在配置TVP5150的时候,利用AVID和VBLK裁剪视频,在寄存器配置的时候,发现对AVID的11h和12h,13h和14h配置,都能够在显示器上显示出变小的视频(水平方向),但是对VBLK的18h和19h配置,无论寄存器怎么设置,视频都不发生变化。我把5150的资料传 ...…

查看全部问答>

STM32F207串口通信

哪位仁兄有207的串口通信程序 能发一份吗 谢谢qlm1006@163.com…

查看全部问答>

msp430 入门 TI MSP430 LaunchPad 欢乐学习季学习交流

刚刚入手msp430 到ti公司申请了两片msp430f149 然后自己搭了最小系统就开始了msp430 我用的是iar for msp430   下面是io口操作的源代码…

查看全部问答>

altium designer 各种封装库

看着比较全的PCB封装 不想自己画封装的快来下载吧 [ 本帖最后由 最美的太阳 于 2012-6-8 09:11 编辑 ]…

查看全部问答>

关于CCS上的低级问题(求高手)

关于CCS上的低级问题(求高手) 本人新手,在CCS上进行512X512图像的小波变换,编译链接都正确,但是load数据运行时发生以下错误Error: Illegal opcode (422a0000) at pc = 0x00000004 Illegal opcode at pc = 0x00000004  在线跪求哪位 ...…

查看全部问答>