assembly
AssemblycodeforAMD8753Hchip.This is a hobby project. The chip is a microcontroller. The program canallow you to turn on household applications with any remote control thatyou may have. What you will need to modify will be the bit patterns accordingto the particular remote control that you have. And of course, you willneed to connect the appliances to the chip. Check out the farnellwebsite for specifications of the chip.$PAGINATE$TITLE(remote control decoder)$PG PW=132$SI$QUIET$SHOWMACS DEFSEG DSEG,START=08H,CLASS=DATA,ABSOLUTE DEFSEG CSEG,START=00H,CLASS=CODE,ABSOLUTE DEFSEG BSEG,START=00H,CLASS=BIT,ABSOLUTE DEFSEG XDSEG,START=0000H,CLASS=XDATA,ABSOLUTE DEFSEG XDSEG1,START=0000H,CLASS=XDATA,ABSOLUTE*************************************************************************** pattern definition for TIVO remotes:* 1 start bit followed by 12 data bits** ---_____- __- --- in 1 ms time frames** start '1' '0'* low for 9ms 1 ms 1 ms*** Define equates for this pattern. Set valid window for each duration.**start_min equ 4200 ;start if high for between 4200us and 4400usstart_max equ 4500bitsize equ 1000 ;< 1ms bit is low, > 1ms bit is highstart_conf equ 5000 ;must beasserted low for at least this time to qualify IR signalbit_length equ 32 ;no. of data bits in patternstart_timeout %macro time clr tf0 clr tr0 mov th0,# high (0ffffh-time) mov tl0,# low (0ffffh-time) setb tr0 %endmstart_timeout1 %macro time clr tf1 clr tr1 mov th1,# high (0ffffh-time) mov tl1,# low (0ffffh-time) setb tr1 %endmwindow_compare %macro var,first,second %gensym win2 clr c mov a,var+1 subb a,#low first mov a,var subb a,#high first jc win2 mov a,var+1 subb a,#low second mov a,var subb a,#high second cpl cwin2 %endmrr0 equ 0rr1 equ 1rr2 equ 2rr3 equ 3rr4 equ 4rr5 equ 5rr6 equ 6rr7 equ 7iand equ b.4ior equ b.5ixor equ b.6 seg bseg org 0 seg dseg org 8time ds 2result ds 1p0_image ds 1p1_image ds 1p2_image ds 1p3_image ds 1lightpattern ds 1new_command ds 1 seg cseg org 00h jmp main ;reset vector org 03h ;ex0 jmp changestate org 0bh ;t0 jmp main org 13h ;ex1 jmp IRreceive org 1bh ;t1 jmp main org 23h ;ser jmp main org 2bh ;t2 jmp main****************************************************************** main routine*****************************************************************main mov p0,#0ffh ;switch off open collectors mov p0_image,#0ffh mov p1,#0ffh mov p1_image,#0ffh mov p2,#0 mov p2_image,#0 mov p3,#0ffh ;input mode mov p3_image,#0ffhmain2 mov sp,#40h mov ie,#0 ;disable interrupts mov ip,#00000100b ;all intpts same priority mov tmod,#00010001b ;16-bit timer/counter mov tcon,#00000101b ;INT1/0 edge triggered mov th1,#0 mov tl1,#0****************************************************************** Configure start status***************************************************************** mov lightpattern,#0 ;initialise light pattern #0 mov new_command,#0 setb ex0 setb ex1 setb ealoop mov pcon,#1b ;idle mode mov a,new_command jz loopgot_new mov new_command,#0 call do_command jmp loop ****************************************************************** Change State*****************************************************************changestate clr ex0 ;clear int 0 mov a,lightpattern inc a mov lightpattern,a mov p1_image,a mov p1,a setb ex0 reti ****************************************************************** IR Receiver Interrupt service routines*****************************************************************IRreceive clr ex1 ;disable INT1 push acc push b start_timeout start_conf ; -____qualifyIR jb p3.3,j_falsealarm ;not start bit, false alarm jnb tf0,qualifyIR jnb p3.3,$ ;wait for startbit start_timeout start_maxwait0 jb p3.3,foundstartbit ;wait for bitto negate __- jnb tf0,wait0j_falsealarm jmp falsealarm ;signal didnot negate within start_out, false alarm againfoundstartbit clr tr0 ;stop timer 0 andnote timing mov a,tl0 xrl a,#11111111b clr c subb a,#low start_min mov a,th0 xrl a,#11111111b subb a,#high start_min jnc got_start jmp falsealarm ;error conditiongot_start mov r0,#0 ;data in r3:r2:r1:r0 mov r1,#0 mov r2,#0 mov r3,#0 mov r4,#bit_lengthwaitstartframe jnb p3.3,readnextbit jnb tf0,waitstartframe jmp falsealarm ;signal did not assertwithin start_out, false alarm againreadnextbit jnb p3.3,readnextbit ;wait to readfirst bit clr tf1 clr tr1 mov th1,#0 mov tl1,#0 setb tr1 ;start timer1wait_low jnb p3.3,found_low jnb tf1,wait_low ;wait for signalto assert jmp falsealarm ;65ms passed withno signalfound_low clr tr1 ;stop timer1 clr c mov a,tl1 subb a,#low bitsize mov a,th1 subb a,#high bitsize cpl c ;carry set if signalhigh > bitsize mov a,r0 rlc a ;rotate left throughcarry (carry set if bit is asserted) mov r0,a mov a,r1 rlc a mov r1,a mov a,r2 rlc a mov r2,a mov a,r3 rlc a mov r3,a djnz r4,readnextbit; Check table for valid IR command; mov dptr,#remote_table mov b,#(end_remote_table-remote_table)/4cmp_loop mov a,#0 movc a,@a+dptr inc dptr xrl a,r3 jnz next_command1 ;mov p1, #11111110b ;*testLED1 movc a,@a+dptr inc dptr xrl a,r2 jnz next_command2 ;mov p1, #11111101b ;*test LED2 movc a,@a+dptr inc dptr xrl a,r1 jnz next_command3 ;mov p1, #11111011b ;*test LED3 movc a,@a+dptr xrl a,r0 jnz next_command3 ;mov p1, #11110111b ;*test LED4match mov a,#(end_remote_table-remote_table)/4 clr c subb a,b ;reg a contains outputtable offset inc a mov new_command,afalsealarm pop b pop acc setb ex1 retinext_command1 inc dptrnext_command2 inc dptrnext_command3 inc dptr djnz b,cmp_loop sjmp falsealarm ****************************************************************** Do command* Input ACC=command code*****************************************************************do_command cjne a,#5,not_cycling;; cycle light pattern; mov a,lightpattern inc a cjne a,#(end_cycle_pattern-cycle_pattern),not_end_pattern clr anot_end_pattern mov lightpattern,a mov dptr,#cycle_pattern movc a,@a+dptr sjmp output_portnot_cycling cjne a,#6,not_auto_pattern jmp auto_pattern_startnot_auto_pattern cjne a,#7,not_power;; POWER BUTTON; mov a,p1_image cjne a,#(00001111b xor 11111111b),all_on mov a,#(00000000b xor 11111111b) sjmp output_portall_on mov a,#(00001111b xor 11111111b) sjmp output_portnot_power: cjne a,#8,not_flash mov a,p1_imageflashloop xrl a,p1_image xrl a,#11111111b mov p1,a mov r7,#8flashdelay1 clr tf0 jnb tf0,$ djnz r7,flashdelay1 mov r6,new_command cjne r6,#0,exitflash sjmp flashloopexitflash mov a,p1_image sjmp output_portnot_flash mov dptr,#output_table movc a,@a+dptr ;output in reg a mov b,a mov a,p1_image ;get original p1 output xrl a,b ;toggle related bitoutput_port mov p1_image,a mov p1,a retauto_pattern_start mov a,#0 ;starting pattern #0 clr tr0 mov th0,a mov tl0,a setb tr0auto_pattern_loop mov r6,a mov dptr,#auto_pattern movc a,@a+dptr mov p1_image,a mov p1,a;; Cycle the display light patten with the followingtimer; mov r7,#18delay clr tf0 jnb tf0,$ djnz r7,delay mov r5,new_command cjne r5,#0,exit_auto_pattern inc r6 mov a,r6 cjne a,#(end_auto_pattern-auto_pattern),auto_pattern_loop sjmp auto_pattern_startexit_auto_pattern ret ****************************************************************** Output pattern table*****************************************************************output_table db 00000001b ;dummy db 00000001b ;1 - toggle db 00000010b ;2 - toggle db 00000100b ;3 - toggle db 00001000b ;4 - toggleend_output_table****************************************************************** Special function table*****************************************************************cycle_pattern ;5- cycle pattern db 00000001b xor 11111111b db 00000101b xor 11111111b db 00000111b xor 11111111b db 00001010b xor 11111111b db 00001110b xor 11111111b db 00001111b xor 11111111b db 00000110b xor 11111111b db 00000100b xor 11111111bend_cycle_patternauto_pattern ;6- auto pattern db 00000001b xor 11111111b db 00000011b xor 11111111b db 00000111b xor 11111111b db 00001111b xor 11111111b db 00001110b xor 11111111b db 00001100b xor 11111111b db 00001000b xor 11111111bend_auto_pattern ****************************************************************** Table for remote controller*****************************************************************remote_table db 02h,0fdh,80h,7fh ;1 db 02h,0fdh,40h,0bfh ;2 db 02h,0fdh,0C0h,03fh ;3 db 02h,0fdh,20h,0dfh ;4 db 20h,0dfh,00h,0ffh ;CH UP Cycle pattern db 20h,0dfh,80h,7fh ;CH DN Auto Cyclepattern db 20h,0dfh,10h,0EFh ;POWER db 20h,0dfh,38h,0C7h ;MTS; db 20h,0dfh,0A8h,57h ;5; db 20h,0dfh,68h,97h ;6end_remote_table end geovisit();
|
|