NEED HELP..
Discussion in "General help Guidance and Discussion" started by hemghosh04 Sep 19, 2013.
Thu Sep 19 2013, 12:45 pm
Hi Ajay sir,
i need your help to implement a part of my project (Using AT89C2051)
Problem:
cjne a,#01,skip
When ever this condition is satisfy i.e accumulator value is #01
i want perform this,
Bit of the port 3 set one by one
i.e P3.0 is set others are clr
then if again accumulator is #01
it will set the bit P3.1 AND CLR the others
likewise p3.2,p3.4,p3.5,p3.7 (but p3.3 & p3.6 will be unaffected during this operation)
Similarly,
if cjne a,#02,skip1 this condition is satisfy do the above things but in reverse order
i.e set bit p3.7 , p3.5, p3.4,p3.2,p3.1,p3.0 accordingly.(it is like up/down counter)
Can you please help me to write a programme for this ?
Thanks
i need your help to implement a part of my project (Using AT89C2051)
Problem:
cjne a,#01,skip
When ever this condition is satisfy i.e accumulator value is #01
i want perform this,
Bit of the port 3 set one by one
i.e P3.0 is set others are clr
then if again accumulator is #01
it will set the bit P3.1 AND CLR the others
likewise p3.2,p3.4,p3.5,p3.7 (but p3.3 & p3.6 will be unaffected during this operation)
Similarly,
if cjne a,#02,skip1 this condition is satisfy do the above things but in reverse order
i.e set bit p3.7 , p3.5, p3.4,p3.2,p3.1,p3.0 accordingly.(it is like up/down counter)
Can you please help me to write a programme for this ?
Thanks
Thu Sep 19 2013, 04:59 pm
you can do something like this, its a pseudo code but implement it in assembly
Let us know if you have any questions.
if (a == 1) { for (i = 0; i < 8; i++) P3 = 1 << i; } else if (a == 2) { for (i = 0; i < 8; i++) P3 = 0x80 > > i; }
Let us know if you have any questions.
Thu Sep 19 2013, 05:17 pm
Thanks for reply,
But sir i need it in ASM format,not in C,because my rest programme is in ASM format.Please help.
But sir i need it in ASM format,not in C,because my rest programme is in ASM format.Please help.
Fri Sep 20 2013, 10:22 am
I gave you a pseudo code so that you can write asm code using that logic. CJNE is nothing but your if loop. so rest of the part you have to do yourself. I can help you modify your code if you write something. But we do not give out ready codes.
Here are your hints to go ahead:
1. use DJNZ instruction for looping
2. use RR and RL for bit shifting.
Here are your hints to go ahead:
1. use DJNZ instruction for looping
2. use RR and RL for bit shifting.
Fri Sep 20 2013, 10:30 am
Sir,
can i do by using register concept? like
can i do by using register concept? like
COUNT1 equ r6 mov COUNT1,#05 MOV DPTR,C200H MOVX @DPTR,#00 INC DPTR MOVX @DPTR,#01 INC DPTR movX @DPTR,#02 INX DPTR MOVX @DPTR,#04 INC DPTR MOVX @DPTR,#16 INC DPTR MOVX @DPTR,#32 INC DPTR MOVX @DPTR,#128 skip0: cjne a,#1,skip1 ;for P3.0 to P3.7 MOV P3,@DPTR INC COUNT1 INC DPTR DJNZ COUNT1,skip0 ljmp main skip1: cjne a,#2,exit ;for P3.7 to P3.0 MOV P3,@DPTR DEC COUNT1 DEC DPTR DJNZ COUNT1,skip1 ljmp main
[ Edited Fri Sep 20 2013, 11:42 am ]
Fri Sep 20 2013, 11:42 am
there is no such instruction as "MOV P3,@DPTR". you can do instead like this
and instead of using external ram you can use internal ram if you want. like after 50H area etc. its almost free to use. But rotation can be efficient way to do it you don't have to fill up memory.
MOVX A, @DPTR MOV P3, A
and instead of using external ram you can use internal ram if you want. like after 50H area etc. its almost free to use. But rotation can be efficient way to do it you don't have to fill up memory.
Fri Sep 20 2013, 03:36 pm
I feel more comfortable with hex values you should have 8 values for 8 pins e.g.
0x1, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
you can use internal ram instead of external. why to burden. store in 50h location of ram.
0x1, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
you can use internal ram instead of external. why to burden. store in 50h location of ram.
Fri Sep 20 2013, 09:07 pm
ok,Thanks,just guide me if i want to load some HEX value says 01,02,04,08,16,32 in the location 50H,51H,52H,53H,54H accordingly.what will be the code for this.
Fri Sep 20 2013, 09:59 pm
The best way to do this depends on exactly what the project does.
For instance you say
"but p3.3 & p3.6 will be unaffected during this operation"
Do you mean p3.3 + p3.6 will always be 0, or they will be in use.
If they are used, then what for ?
Have you been given a guide as to what method to use ?
For instance you say
"but p3.3 & p3.6 will be unaffected during this operation"
Do you mean p3.3 + p3.6 will always be 0, or they will be in use.
If they are used, then what for ?
Have you been given a guide as to what method to use ?
Powered by e107 Forum System