;********************************************************************** ; * ; Filename: sirc10fv15.asm * ; Date: 04/02/2010 * ; File Version: 5 * ; * ; Author: Pete Griffiths * ; Company: Picprojects * ; * ;********************************************************************** ; * ; Copyright 2010 Pete Griffiths ; ; 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 3 of ; the License, or 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, see http://www.gnu.org/licenses/ ; * ;********************************************************************** ; * ; Files Required: P10F20x.INC * ; Code will build for 10F200/10F202 * ; * ; Datasheet: * ; http://ww1.microchip.com/downloads/en/DeviceDoc/41239D.pdf * ;********************************************************************** ; * ; Notes: * ; * ; n/c -|1 8|- GP3 irrx_in * ; +5V (Vdd) -|2 7|- Vss (Gnd) * ; rlyvbst GP2 -|3 6|- n/c * ; rl2 GP1 -|4 5|- GP0 rly * ; * ; * ;********************************************************************** ; Operation * ; - One IR receiver input for 12-bit SIRC data format * ; - Two relay control outputs * ; - One relay voltage boost * ; * ; When a relay output is turned on, the rlyvbst output is set high * ; for a miniumum of 96mS. This can be used to turn on a voltage boost * ; while the relay turns on, then reduce the holding voltage to about * ; 50% which reduces the total power consumde by the controller. * ; * ; * ; Schematic and more information can be found at: * ; http://picprojects.org.uk/projects/ * ;********************************************************************** ; ------------------------------------------------------------------------------------- ; IMPORTANT ; TMR0 prescaler is 1:16 giving TMR0 clock of 16uS with 4MHz internal oscillator ; Timer load value is calculated as 256 - ( delay_uS / 16 ) ; Since there is no interrupt on the 10F2xx PIC, the timer is polled to detect ; when it rolls over to zero. The timer is clocked at 16uS so any polling loop ; must execute in less than 16uS or it may increment through zero before it is ; 'seen' in by the poller. This must be taken into account before modifying any ; part of this code were the TMR is polled. ; ------------------------------------------------------------------------------------- ifdef __10F200 list p=10F200 ; list directive to define processor #include ; processor specific variable definitions endif ifdef __10F202 list p=10F202 ; list directive to define processor #include ; processor specific variable definitions endif __CONFIG _MCLRE_OFF & _CP_OFF & _WDT_OFF ; '__CONFIG' directive is used to embed configuration word within .asm file. ; The lables following the directive are located in the respective .inc file. ; See respective data sheet for additional information on configuration word. ;******************************************************************************************* ; CONSTANT DEFINITIONS ; ; Constants for 12 bit SIRC C.cmd.bits equ .7 ; Number of bits in the SIRC command C.dev.bits equ .5 ; Number of bits in the SIRC device ; ;******************************************************************************************* ; ; USER CONFIGURABLE PARAMETERS FOR 12 BIT SIRC DEVICE ID & COMMAND NUMBERS ; edit the values here to suit application / sirc transmitter being used then ; reassemble code. This code does not support 15 or 20 bit SIRC ; ; Defaults provided below are for Sony TV remote. ; See http://www.sbprojects.com/knowledge/ir/sirc.htm for additional codes and SIRC FAQ. ; ; device id: ; Television = 1 ; ~~~~~~~~~~~~~~~~~~~~ ; command codes: ; keypad button #1 = 0 ; keypad button #2 = 1 ; keypad button #3 = 2 ; keypad button #4 = 3 ; keypad button #9 = 8 ; keypad button #0 = 9 radix decimal ; set radix for decimal values C.dev.value equ 1 ; Controller responds to this SIRC device id ; Set any command value to 255 to disable that command. For example if you only want momentary ; output action, set C.cmd0value thru C.cmd5.value == 255 then only C.cmd6.value and C.cmd7.value ; are active. ; e.g. C.cmd0.value equ 255 ; would disable Toggle Rly0. ; Command number ; Latching action command codes C.cmd0.value equ 0 ; Command 0 Toggle Rly0 C.cmd1.value equ 1 ; Command 1 Toggle Rly1 C.cmd2.value equ 3 ; Command 2 Turn off Rly0 C.cmd3.value equ 4 ; Command 3 Turn off Rly1 C.cmd4.value equ 9 ; Command 4 Turn on Rly0 + Rly1 C.cmd5.value equ 8 ; Command 5 Turn off Rly0 + Rly1 ; Momentary action command code C.cmd6.value equ 6 ; Command 6 Rly0 momentary on C.cmd7.value equ 7 ; Command 7 Rly1 momentary on radix hex ; set radix back to hex ;******************************************************************************************* ;***** VARIABLE DEFINITIONS ; GPR starts at 0x0C for 10F202 / 10F206 ; GPR starts at 0x10 for 10F200 / 10F204 cblock 0x10 flag ; application flag bits live here now ; port state used to detect high-to-low edge on IR data last ; port state used to detect high-to-low edge on IR data shift.cnt ; counter for SIRC bits received ir.dev ; received SIRC device id ir.cmd ; received SIRC command value timerL ; repeat receive hold down timer (low byte) timerH ; repeat receive hold down timer (high byte) port.copy ; work variable holds data to be output on physical I/O port dev.active cmd.active endc ;********************************************************************** ; I/O port function specific names irrx = GP3 ; input: ir receiver data in rly0 = GP0 ; output: relay output 0 (active high) rly1 = GP1 ; output: relay output 1 (active high) rly.vboost = GP2 ; output: relay voltage boost control (active high) ;********************************************************************** ; Flag bit definitions F.error equ .0 F.momentary equ .1 F.newrx equ .2 ;********************************************************************** ORG 0x0FF ; processor reset vector ; Internal RC calibration value is placed at location 0x1FF by Microchip ; as a movlw k, where the k is a literal value. ORG 0x000 ; coding begins here ; Initialise PIC start movwf OSCCAL ; update register with factory cal value clrwdt ; options 1:16 prescaler to Tmr0, T0CS = Int Osc, Enable weak pull-ups ; weak pull holds GP3 high as it is set for internal MCLRE movlw ~(1<