Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 17th, 2010, 2:35 PM   #1
maxmap
Newbie
 
Join Date: Dec 2010
Posts: 1
Rep Power: 0 maxmap is on a distinguished road
help with this code

hello to all, i've been looking for help all over the internet without luck and i hope i find some here.

im working on this home automation project where you could control devices over a cell phone's bluetooh. the hardware has a micro-controller for switching the right device as wanted.
what im trying to figure out is that im writing the phones application but i can't figure out what kind of command that i can send to the micro-controller to activate a cretin pin or port.

now if im using hyperterminal to do so, and to my understanding, is it correct if i send A>0A>39 to activate port1
and how to put that in a string using sendChar()

this might be confusion so let me know if you needed more details.
id really appreciate any kind of help,

the assembly code is as follows

INCLUDE REG_51.PDF

LOAD1 EQU P1.0
LOAD2 EQU P1.1
LOAD3 EQU P1.2
LOAD4 EQU P1.3
LOAD5 EQU P1.4
LOAD6 EQU P1.5
LOAD7 EQU P1.6
LOAD8 EQU P1.7

DSEG ; This is internal data memory
ORG 20H ; Bit adressable memory


MOBILE: DS 3
COUNTER: DS 1


CSEG ; Code begins here
; ---------==========----------==========---------=========---------
; Main routine. Program execution starts here.
; ---------==========----------==========---------=========---------
ORG 00H ; Reset
AJMP MAIN

ORG 0023H
AJMP SERIAL
; ---------==========----------==========---------=========---------

MAIN: MOV SP,#40H
MOV TMOD,#20H ;initilize serial port
MOV TH1,#0FDH ;Slect 9600 baud rate
MOV SCON,#50H
MOV A,PCON
SETB ACC.7
MOV PCON,A
MOV IE,#10010000B
SETB TR1 ;start timer
MOV COUNTER,#00H
MOV P1,#00H
AJMP $
;**************************************************************************
SERIAL:
JB TI,TRAS1
MOV A,SBUF
CJNE A,#'A',DOWNW
MOV COUNTER,#00H
AJMP DOWN1
TRAS1: AJMP TRAS
DOWNW:CJNE A,#0AH,DOWNW1
CALL DEVICE_DECODE
AJMP DOWN1
DOWNW1:MOV A,COUNTER
CJNE A,#01H,SD1
MOV MOBILE,SBUF
AJMP DOWN1
SD1: CJNE A,#02H,DOWN1
MOV MOBILE+1,SBUF
DOWN1:INC COUNTER
CLR RI
RETI
TRAS: CLR TI
RETI
;**************************************************************************
DEVICE_DECODE:
MOV A,MOBILE ;LOAD 1
CJNE A,#31H,SDF1
MOV A,MOBILE+1
CJNE A,#31H,SDF2
SETB LOAD1
AJMP SDF1
SDF2: CJNE A,#32H,SDF1
CLR LOAD1
SDF1:

MOV A,MOBILE ;LOAD 2
CJNE A,#32H,SDF11
MOV A,MOBILE+1
CJNE A,#31H,SDF21
SETB LOAD2
AJMP SDF11
SDF21: CJNE A,#32H,SDF11
CLR LOAD2
SDF11:

MOV A,MOBILE ;LOAD 3
CJNE A,#33H,SDF12
MOV A,MOBILE+1
CJNE A,#31H,SDF22
SETB LOAD3
AJMP SDF12
SDF22: CJNE A,#32H,SDF12
CLR LOAD3
SDF12:

MOV A,MOBILE ;LOAD 4
CJNE A,#34H,SDF14
MOV A,MOBILE+1
CJNE A,#31H,SDF24
SETB LOAD4
AJMP SDF14
SDF24: CJNE A,#32H,SDF14
CLR LOAD4
SDF14:
MOV A,MOBILE ;LOAD 5
CJNE A,#35H,SDF15
MOV A,MOBILE+1
CJNE A,#31H,SDF25
SETB LOAD5
AJMP SDF15
SDF25: CJNE A,#32H,SDF15
CLR LOAD5
SDF15:
MOV A,MOBILE ;LOAD 6
CJNE A,#36H,SDF16
MOV A,MOBILE+1
CJNE A,#31H,SDF26
SETB LOAD6
AJMP SDF16
SDF26: CJNE A,#32H,SDF16
CLR LOAD6
SDF16:
MOV A,MOBILE ;LOAD 7
CJNE A,#37H,SDF17
MOV A,MOBILE+1
CJNE A,#31H,SDF27
SETB LOAD7
AJMP SDF17
SDF27: CJNE A,#32H,SDF17
CLR LOAD7
SDF17:

MOV A,MOBILE ;LOAD 8
CJNE A,#38H,SDF18
MOV A,MOBILE+1
CJNE A,#31H,SDF28
SETB LOAD8
AJMP SDF18
SDF28: CJNE A,#32H,SDF18
CLR LOAD8
SDF18:

MOV A,MOBILE ;LOAD 8
CJNE A,#39H,SDF19
MOV P1,#0FFH
SDF19:

MOV A,MOBILE ;LOAD 8
CJNE A,#30H,SDF10
MOV P1,#00H
SDF10:
RET

end
maxmap is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
code structure lapta Delphi 1 Dec 27th, 2010 9:19 AM
Does anyone know what this line of code does? neorich2002 Other Programming Languages 3 Jul 5th, 2010 1:23 PM
weird Allocation/Deallocation error in C code Abhijit Bose C 9 Jun 14th, 2010 6:33 AM
Incorporating javascript code into java application csrocker101 Java 1 Feb 11th, 2008 6:36 AM
Code suggestions Mad_guy Perl 0 Feb 18th, 2005 10:31 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:59 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC