Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

RC5 decoding using TSOP1738 and 8051

Status
Not open for further replies.

mvgohil

Newbie level 5
Newbie level 5
Joined
Oct 5, 2010
Messages
9
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,354
hello frnds,

i got this code.

But delay of detecting toggle bit is 3.024ms that i dont understand.

it should be( 1.778+1.778+1.something) according to me .

plz help me............
Code:
/**********************************************************************
 *                    Phillips RC5 Decoding
 *
 *         Author:  Ajay Bhargav
 *              Description: This software is for Phillips RC-5 remote
 *                decoding. Pin used for reception is P3.3 while
 *                you can use any pin as per your requiremnet.
 *                This program is written for 8051 MCU running 
 *                at 11.0592MHz.
 *
 *         Usage: After the decoding the Address is stored in the
 *                ADDR variable and command is stored in the CMD.
 *                The flip bit is also stored to check whether the
 *                button is pressed once or not.
 *
 *         
 *                  Having a Doubts? Please post at
 *                  [url=https://www.8051projects.net/forum.html]Forum : 8051 Microcontroller Projects AVR PIC Projects Tutorials Ebooks Libraries codes[/url]
 *
 **********************************************************************/

VAR1	equ r7                  ;Temporary Variable
TEMP	equ 10H		        ;Temp variable
COUNT	equ 11H		        ;Count
ADDR	equ 12H		        ;Device address
CMD	equ 13H 		;Command
FLIP	bit 00H		        ;Flip bit
TOG	bit 01H 	        ;Temp bit for flip
IR	equ P3.3	        ;IR Receiver connected to this pin
	
	org 00H			;Start of prog
	mov sp,#50H		;Stack pointer initialization
	clr TOG			;Clear temp bit
	
main:
	jb IR,$			;Wait for first bit
	mov VAR1,#255           ;3.024mS delay
	djnz VAR1,$
	mov VAR1,#255
	djnz VAR1,$
	mov VAR1,#255
	djnz VAR1,$
	mov VAR1,#255
	djnz VAR1,$
	mov VAR1,#255
	djnz VAR1,$
	mov VAR1,#100
	djnz VAR1,$
	mov c,IR		;Read Flip bit
	mov FLIP,c
	clr A
	mov COUNT,#5	        ;Count for address
fadd:
	mov VAR1,#255	        ;1.728mS delay for each bit
	djnz VAR1,$
	mov VAR1,#255
	djnz VAR1,$
	mov VAR1,#255
	djnz VAR1,$
	mov VAR1,#4
	djnz VAR1,$
	mov c,IR
	rlc a
	djnz COUNT,fadd
	mov ADDR,A		;Save the address
	clr a
	mov COUNT,#6	        ;Count for Command
fcmd:
	mov VAR1,#255	        ;1.728mS Delay for each bit
	djnz VAR1,$
	mov VAR1,#255
	djnz VAR1,$
	mov VAR1,#255
	djnz VAR1,$
	mov VAR1,#4
	djnz VAR1,$
	mov c,IR
	rlc a
	djnz COUNT,fcmd
	mov TEMP,CMD        	;Save the old command
	mov CMD,a		;Save the new command
	mov a,ADDR		;Cheack for valid address
	cjne a,#00,nvalid
	mov a,TEMP
	cjne a,CMD,valid	;Check for valid command
nvalid:
	ljmp main
valid:				;Key press check
	clr a
	mov c,FLIP
	rlc a
	mov TEMP,a
	clr a
	mov c,TOG
	rlc a
	cjne a,TEMP,valid1
	sjmp nvalid
valid1:
	mov c,FLIP
	mov TOG,c
	mov a,CMD
	clr c
/*--------------------

Your code goes here...
CMD contains the current command!
Just need to compare.. :)

----------------------*/

	END			;End of program
 
Last edited by a moderator:
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top