Discussion in "New Ideas regarding projects" started by    caze    Jun 29, 2008.
Sat Sep 06 2008, 12:53 am
#31


Hello Mr.shabiul,

i feel you are trying to do too many things at the same time, pl. follow a step by step approach.

the solution i offered here is for this particular Challenge, so the connecting of Int0 pin with other input port pins works in this context and you don't have to connect it this way always in your other circuits.

now about the timer delay.

you have to use timer ISR ( interrupt Service Rotuine). in Data seg ( i,e RAM) define variables by some name like count_1......count_10 and also 10 flags by name like Flag_1.....Flag_10 and now read the algorithm carefully (point no.5):

5) in the timer0 ISR declare 10 counters (use registers/variables) check which flag/s is high( already set high in the Ex int.ISR), if a match is found increment that particular counter/s and reti continue till you reach 200 decimal ( 50mSec X 200 times = 10secs) once the counters reach 200 then stop the device and clear the flag/s






Arun

Arun Kumar V



it is because my project also require 4 inputs which your solution offer 10 inputs, i guess it is the same thing right? So do I need to connect those 4 inputs to INT0?

by the way, i had read ur algorithm very carefully,but i m still not quite clear about it.(well, i m just a new learner to assembly coding)
5) in the timer0 ISR declare 10 counters (use registers/variables) check[/color] which flag/s is high( already set high in the Ex int.ISR), if a match is found increment that particular counter/s and reti
May you explain tis part further?
Hope to hear from u soon


[ Edited Sat Sep 06 2008, 03:16 am ]
Sat Sep 06 2008, 11:05 pm
#32
How to define others variables rather than R0-R7 in register banks 0
and without using register banks 1
becoz changing register banks looks complicated...
and my R0-R7 in register banks 0 is fully occupied...

For example
FLAG1: DS 1
den in main program
MOV FLAG1,#01H

tis giv segment type mismatch in my compliler

wat is the problem?


[ Edited Sat Sep 06 2008, 11:20 pm ]
Sat Sep 06 2008, 11:13 pm
#33

Shabiul, may be you are forgetting the 256 bytes RAM on board 8052, declare Variables in RAM and In Assembly this is how it can be done:

DSEG ORG 0020H
COUNTER_1: DS 1
COUNTER_2: DS 1

and for FLAGS

FLAG_1 BIT 1
FLAG_2 BIT 1
...................................



Arun
Sat Sep 06 2008, 11:21 pm
#34
why is FLAG_1 BIT 1 while COUNTER_1: DS 1?

by the way, there is alot questions in the previous posts tat you din answer me...

regarding checking the flag, THE FLAG is just normal variable or interrupt FLAG?


[ Edited Sat Sep 06 2008, 11:29 pm ]
Sat Sep 06 2008, 11:50 pm
#35
shabiul, you have edited your previous post after my reply ( see the time stamp, i replied at 11.15 pm and you modified your last reply after reading my answer at 11.21pm)

don't repeat this sought of thing.

now about your problem, bit and DS, before i clear your doubt can you tell me the difference between Port1 and Port pin 1.0


i can proceed only when you answer my above question


Arun
Sun Sep 07 2008, 12:07 am
#36
i edit my post just because i got new question and i dun wan to double post.
about ur question, Port1 means the whole port1.0-1.7, port pin 1.0 means only the pin.
correct me if wrong.

by the way i mean u did not answer my previous 2-3 posts but not the last post.


[ Edited Sun Sep 07 2008, 12:17 am ]
Sun Sep 07 2008, 08:07 am
#37

about ur question, Port1 means the whole port1.0-1.7, port pin 1.0 means only the pin.correct me if wrong.



other way of putting it would be, port1.0 is a bit of port1 and port1 is a 8bit port.

so port1 (or any 8 bit port ) can be called as a register which is both Bit & byte addressable (i,e you can write or read a single port bit or full 8 bit register).


why is FLAG_1 BIT 1 while COUNTER_1: DS 1?



when you declare a variable in RAM area, you have to specify to compiler the size of that variable,

for eg:

COUNTER_1: DS 1 ; means the variable counter_1 is one byte wide ( like a 8 bit register)

and now declaring a flag,

FLAG_1 BIT 1 ; flag_1 is a single bit and not whole 8 bit Register.


now data moves with byte wide Variable and bit flag:

to write/read a 8 bit variable:

MOV COUNTER_1,#0FFH ; move value 255d to counter_1
MOV A,COUNTER_1 ; read value of Counter_1 to Accu

FLAG1: DS 1
den in main program
MOV FLAG1,#01H

tis giv segment type mismatch in my compliler

wat is the problem?



now with Bit :

how would you turn On or Turn Off a port bit ?

SETB P1.1
CLR P1.1

same way you can Set or clear a bit Flag:

SETB FLAG_1
CLR FLAG_1

but cannot use byte instructions with single bit variable/flag

MOV FLAG_1,#0FFH ; is wrong and gives Error

it is like writing :

MOV P1.1,#0FFH ; which is like writing 8 bit value to a single port pin (bit), this is called
" illegal syntax " by the compiler/assembler


Flag/s are used to indicate only two states i,e 1 or 0 ( a light is ON or OFF)
Variable is used to store data/value which often changes or varies ( Seconds Variable of a Clock)


Arun





 Mr.Shabiul like this.
Sun Sep 07 2008, 09:09 am
#38
@ Mr.shabiul,

I Bet even your College Professor wouldn't have explained the whole concept with such clarity as Arun did.

so the least you can do is " Thank " Arun and other moderators who are taking pain in explaining the concepts from root level.

the college professors are "paid "to solve your problems but they do not do that ( if they did, you wouldn't be asking for help in forums)

on the other hand Moderators here are doing Free social service by sharing their knowledge.

i should say you folks (your fellow country men) are Lucky to be members of this forum, because other forums Like popular 8052.com would not entertain assignments and home works ( they straight away lock/delete your posts) so thank God and thank the Mods by pressing the "Thanks button"

Sun Sep 07 2008, 04:48 pm
#39
Ya, i know moderators here are very nice and willing to help, tats why i stick to here.
I keep refresh the page to see if they had replied me or not, becoz i m desperate & my project is running out of time. Maybe i had ask too much question and i did not speak in proper manner, but i really appreciate their help.

the college professors are "paid "to solve your problems but they do not do that ( if they did, you wouldn't be asking for help in forums)


maybe they did,maybe they did not,its not for me to comment about it.
Well maybe the problem is with myself... i m just not good in programming.
and the text book has too little example to refer


[ Edited Sun Sep 07 2008, 05:17 pm ]
Sun Sep 07 2008, 04:59 pm
#40
@Arun

thanks, u explained very well n clear. I wonder why i just dun understand such a simple thing be4....
anyway,I m still stuck in tis part 5) n 6)
5) in the timer0 ISR declare 10 counters (use registers/variables) check which flag/s is high( already set high in the Ex int.ISR), if a match is found increment that particular counter/s and reti continue till you reach 200 decimal ( 50mSec X 200 times = 10secs) once the counters reach 200 then stop the device and clear the flag/s
6) even when some devices are running and some other new device/s is triggered the counter for that particular new device is also incremented along with the old running one

How to fullfill part6 conditions? just by doing the code in part5 will do?
can i do like tis for part 5?below is sample timer ISR for 2 switches & flag1 flag2 already SETB in external INT.
T1_ISR:
PUSH ACC
PUSH PSW
MOV A,FLAG1
CJNE A,#01H,COUNTER1
CLR TR1
DJNZ R5,CONTINUE
MOV R5,#20D
DJNZ R6,CONTINUE
SETB LED1
MOV R6,#30D

CLR FLAG1 ;

COUNTER1:
MOV A,FLAG2
CJNE A,#01H,RETURN
CLR TR1
DJNZ R5,CONTINUE
MOV R5,#20D
DJNZ R6,CONTINUE
SETB LED2
MOV R6,#30D

CLR FLAG2

RETURN:
POP PSW
POP ACC

CONTINUE:
MOV TL1,#0B0H ;Lower Byte ; 50 mS DELAY VALUES ( 12 Mhz XTAL)
MOV TH1,#03CH ;Upper Byte
SETB TR1

RETI

INT0_ISR:
.
.
.
RETI




[ Edited Sun Sep 07 2008, 05:11 pm ]

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Clydehet
Wed May 01 2024, 06:44 pm
Davidoried
Wed May 01 2024, 06:11 pm
KevinTab
Sun Apr 28 2024, 05:35 am
Tumergix
Sun Apr 28 2024, 12:59 am
StevenDrulk
Sat Apr 27 2024, 08:47 pm
StephenHauct
Sat Apr 27 2024, 09:38 am
Adamsaf
Sat Apr 27 2024, 07:12 am
Robertphype
Sat Apr 27 2024, 12:23 am