PDA

View Full Version : silly but occured first time



utkarshjain
01-28-2010, 09:21 PM
yesterday when i completed electronics and mechanical portion of my toy car (consiting of 1 at89s52 m.c.u , 1 l293d and 5v converting circuit , 4 wheel-bot, using 1 7.4 volt li-ion battery ) i decided to program it using my 8051 programmer...i removed the reset pin (pin 9) of my robot ,pin6,7,8 connecting them wid programmer and burning it i stucked up when i saw that inspite of giving input i was not able to get the output and instead all ports are getting 5v (high) instead of offering a change in the voltage ...today i went to the institute teacher (i dont want to name him ) spending abt 2 hrs and he said programmer may be faulty...i still think ther may be some error in my programming ...plz check it out...
input ---- pin 1,2,3,4 (coming from my remote)
output---pin 21,22,23,24 (going to l293d)
i am driving 4 motors from a single l293d...kuchh toh output mile..
source code(in assembly):
-------------------------------------
pin1 bit p1.0
pin2 bit p1.1
pin3 bit p1.2
pin4 bit p1.3

;interrupts
;ram declaration
;start of the main program
;constant declaration
stackval equ 70H
org 000H
ajmp poweron
org 0003H ;external interrupts is zero
reti
org 000BH ;for timer 0
reti
org 0013H;external timer1
reti
org 001BH ;T1

reti
org 0023H ;serial
reti
org 002BH ;T2
reti
org 0033H

poweron:
mov sp,#stackval ;moves stackval to 70H
mov p0,#0FFH
mov p1,#0FFH
mov p2,#0FFH
mov p3,#0FFH
mov IE,#00H
mov IP,#00H

mainloop:
acall up
acall left
acall right
acall down
acall sleft
acall sright
sjmp mainloop
up:
jnb pin1,goret
jb pin2,goret
jb pin3,goret
jnb pin4,goret
clr p2.0
setb p2.1
clr p2.2
setb p2.3
ret
down:
jb pin1,goret
jnb pin2,goret
jnb pin3,goret
jb pin4,goret
setb p2.0
clr p2.1
setb p2.2
clr p2.3
ret
left:
jb pin1,goret
jnb pin2,goret
jb pin3,goret
jnb pin4,goret
clr p2.0
setb p2.1
setb p2.2
clr p2.3
ret
right:
jnb pin1,goret
jb pin2,goret
jnb pin3,goret
jb pin4,goret
setb p2.0
clr p2.1
clr p2.2
setb p2.3
ret
sleft:
jnb pin1,goret
jnb pin2,goret
jb pin3,goret
jnb pin4,goret
clr p2.0
setb p2.1
clr p2.2
clr p2.3
ret
sright:
jnb pin1,goret
jb pin2,goret
jnb pin3,goret
jnb pin4,goret
clr p2.0
clr p2.1
clr p2.2
setb p2.3
ret
goret: ret

--------------------------
sleft means slow left and correspondingly for sright

is it necessary to declare p0,p1,p2,p3 as high before giving input??
plz answer these set of questions....

vikas
01-28-2010, 10:44 PM
He he ... reminds me college days ... ASM ... use C. ASM takes too long to do simplest of jobs ....

Why do you guys still stuck on assembly , its a waste of time ... for 99.99 cases :) .

Re-Write it in Kiel C itll be like 8 - 10 lines of code which is human understandable.

utkarshjain
01-29-2010, 12:06 AM
well actually i did course in assembly that's why...well you are also true..i will learn in c also but when i will be able to get free time...

utkarshjain
01-29-2010, 12:07 AM
thanx for ur suggestion

Ulhas
01-29-2010, 09:11 PM
Well if it is not too late switch over to AVR or PIC with MikroC or codevisionavr C cross compilers.
Your life will be much more joyful.