;******************************************************************************* ;** ;** D70 Remote control using a PIC12C508 ;** ;** Written by Rick Huang, Copyright (C) 2004 ;** Revision YYYY/MM/DD ;** Rev 1. 2004/04/26 - Initial release, code base adapted from bike dimmer ;** ;** IR code implemented: ;** 1: 2ms ;** 0: 28ms ;** 1: 0.5ms ;** 0: 1.50ms ;** 1: 0.50ms ;** 0: 3.50ms ;** 1: 0.50ms ;** ;** This program is free software; you can redistribute it and/or modify ;** it under the terms of the GNU General Public License as published by ;** the Free Software Foundation; either version 2 of the License, or ;** (at your option) any later version. ;** ;** This program is distributed in the hope that it will be useful, ;** but WITHOUT ANY WARRANTY; without even the implied warranty of ;** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;** GNU General Public License for more details. ;** ;** You should have received a copy of the GNU General Public License ;** along with this program; if not, write to the Free Software ;** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ;******************************************************************************* ;******************************************************************************* ;** Pinout: ;** GP0 - Delay Fire (Active low) ;** GP1 - N/A ;** GP2 - IR output (Connected to IR diode with 47ohm resistor) ;** GP3 - Master Reset, wake up from sleep (Active low, use pull-up resistor) ;** GP4 - Crystal connection ;** GP5 - Crystal connection(Clock 4MHz) ;******************************************************************************* include __config _XT_OSC & _WDT_OFF & _MCLRE_ON #define _DOUT GPIO, 2 ; Outgoing data #define _M01 GPIO, 0 ; Delay Fire ;******************************************************************************* ;** Memory start at 07h, 25 space available Temp equ 08h Time equ 09h Mode equ 0ah Counter equ 0bh Counter2 equ 0ch ;******************************************************************************* ;** Start of the program Reset: clrf GPIO ; Clear output data movlw b'11000111' ; Presecaler set to /? option ; movlw b'00111011' ; Output GP2 only TRIS GPIO ;------------------------ Preset variable clrf Time clrf Mode movlw b'10000111' ; Set weak pullup to read option ; delay fire WaitMore: btfsc _M01 goto WaitMore movlw b'11000111' ; Reset weak pullup to option ; reduce current ;------------------------ Fire signal movlw d'80' movwf Counter Loop2ms: bsf _DOUT ; 0 Set output high nop nop nop nop nop nop nop nop nop nop nop bcf _DOUT ; 12 nop nop nop nop nop nop nop nop nop decfsz Counter, F ; 22 goto Loop2ms ; 23, (24 goto) movlw d'20' ; 24 movwf Counter2 ; 0 (25) Loop28msO: movlw d'199' ; 0 (1400) movwf Counter ; 1 Loop28msI: nop ; 0 (7) nop ; 1 nop ; 2 nop ; 3 decfsz Counter, F ; 4 goto Loop28msI ; 5, 6 ; Total delay - 7 ins nop ; 1394 nop ; 1395 nop ; 1396 decfsz Counter2, F ; 1397 goto Loop28msO ; 1398, 1399 movlw d'20' movwf Counter Loop05ms: bsf _DOUT ; 0 Set output high nop nop nop nop nop nop nop nop nop nop nop bcf _DOUT ; 12 nop nop nop nop nop nop nop nop nop decfsz Counter, F ; 22 goto Loop05ms ; 23, 24 movlw d'60' ; 24 movwf Counter ; 25 Loop15ms: bcf _DOUT ; 0 Set output high nop nop nop nop nop nop nop nop nop nop nop bcf _DOUT ; 12 nop nop nop nop nop nop nop nop nop decfsz Counter, F ; 22 goto Loop15ms ; 23, 24 movlw d'20' movwf Counter Loop05ms2: bsf _DOUT ; 0 Set output high nop nop nop nop nop nop nop nop nop nop nop bcf _DOUT ; 12 nop nop nop nop nop nop nop nop nop decfsz Counter, F ; 22 goto Loop05ms2 ; 23, 24 movlw d'140' movwf Counter Loop35ms: bcf _DOUT ; 0 Set output high nop nop nop nop nop nop nop nop nop nop nop bcf _DOUT ; 12 nop nop nop nop nop nop nop nop nop decfsz Counter, F ; 22 goto Loop35ms ; 23, 24 movlw d'20' movwf Counter Loop05ms3: bsf _DOUT ; 0 Set output high nop nop nop nop nop nop nop nop nop nop nop bcf _DOUT ; 12 nop nop nop nop nop nop nop nop nop decfsz Counter, F ; 22 goto Loop05ms3 ; 23, 24 sleep ;------------------------ End of file end