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.

i need help in ASM coding?

Status
Not open for further replies.
your are completely wrong in this.
i didn't used rude words or meant anything bad for anyone!!!
how you could say that?! STRANGE how you judge!!!
Almost everyone who replied to you asked: "what you want to do with this code?" (please reread previous answers).
Now let me know what were your answers to those requests? You only attacked the ones who asked for more details trying to help you.
To me this is unpoliteness.

By the way, I have taken a look at the code: to me it is written awfully. Just take a look at the way characters are written in the memory buffer/LCD, not mentioning other parts of the code!
Because you are very reticent to give us more informations on what you want to do, I suggest you to search for more throughly written code samples.
 

I don't code in assembly but if you have read the datasheet, the code wouldn't be difficult for you to read.

Code:
;SQUARE WAVE GENERATION ROUTINE
TMR0_INIT: MOV TL0,#0F0H
MOV TH0,#0DBH

load tmr0 with the offset. the TH0 piece may not be consistent.

this is the initialization routine for tmr0 - it is executed once to set up the tmr0.

Code:
SETB IE.7 ;iNTRUPPUT ENABLE

enable tmr0 interrupt

Code:
SETB IE.1

I bet it enables global interrupt.

Code:
MOV TMOD,#01H ;

it sets tmr0 to mode 1 (16 bit timer)

Code:
NOP
NOP

delays.

Code:
SETB TCON.4 ; SET TR1

set TR0 to start tmr0 - the comment is wrong.

Code:
RET

return?


Code:
;*************************

this is the start of the interrupt routine?

Code:
TIMER0: CLR TCON.4	 ; CLEAR TR1

clears TR0 - turn off tmr0

Code:
CPL P0.7	 ; COMPLEMENT P0.7

flip pin 7 on P0.

Code:
MOV TL0,#0F0H
MOV TH0,#0D0H

load up tmr0 with offset - notice the TH0 inconsistency with the initialization routine?

Code:
SETB TCON.4

set tr0 - start tmr0

Code:
RETI

return from interrupt?

again, it is my guess work based on the datasheet. the code is fairly typical of a timer based approach to generate 50% duty cycle pulses - except that this particular piece of code isn't well written. the timing is controlled by the offsets.

It isn't likely that you will understand the above if you have trouble understanding what a square wave is.
 

hey dude. cool your self. forget all those post. just tell us what do u want. what is ur project concept.


and why are u asking to delete this post, this post may be example for newbie's in what way they should not ask a question
 
Last edited:

here is the C equivalent of it.

Code:
//a simple multi-tasking OS
//each task has a pre-define time slot (XOS_slot), + an idle slot
//user can add up to 255 tasks (including the idle task).
//each task has to take less than the time slot to finish.
//the os uses tmr0 so no task can utilize tmr0

#include <REGX51.H>
#include "gpio.h"

//define the output pin
#define OUT_PORT		P2
#define OUT_DDR			P2
#define OUT_PIN			(1<<7)		//p2.7 is the output pin
//end hardware configuration

unsigned short tmr0_offset;			//tmr0 offset

void tmr0_isr(void) interrupt 1 {	//xos interrupt on tmr0
	TF0=0;							//clear flag - done by hardware
	TH0=(tmr0_offset >> 8);			//reset th0
	TL0=(tmr0_offset & 0x00ff);		//reset tlo
	IO_FLP(OUT_PORT, OUT_PIN);		//flip the out pin
}

void tmr0_init(unsigned short offset) {					//initiate xos
	//set tmr0 to 16 bit timer operation (mode 1)
	TMOD &= 0xf0;						//clear tmod's lower 4 bits
	TMOD |= 0x01;						//not gated, tmr operation, mode 1
	TF0=0;								//clear flag - done by hardware
	
	//define slot size, in tmr ticks
	tmr0_offset=-offset;				//define offset for count-up timer
	
	//set tmr0
	TH0=(tmr0_offset >> 8);				//load th0 with msb of the offset
	TL0=(tmr0_offset & 0x00ff);			//load tl0 with lsb of the offset
	
	//set interrupt
	ET0=1;								//enable tmr0 interrupt
	EA=1;								//enable all  interrupt
	TR0=1;								//turn on tmr0
}

void mcu_init(void) {					//initiate the mcu
}

int main(void) {
	mcu_init();							//initiate the mcu
	tmr0_init(10000);					//time slot to be 10ms.
	
	while (1) {
		
	}
}

in this case, it simply outputs, on P2.7, a pulse with width of 10ms -> 50hz, as shown in this simulation.
 

Attachments

  • C51 TMR0.PNG
    C51 TMR0.PNG
    21.1 KB · Views: 126

ust take a look at the way characters are written in the memory buffer/LCD, not mentioning other parts of the code!
wow, you are so smart. congratulations.
what about P0.7 ???!

...To me this is unpoliteness.
useless talk..
i told you, i'm done in such talk.
so, please, if you can't help then keep silent.
thank you.


I don't code in assembly but if you have read the datasheet, the code wouldn't be difficult for you to read....
Dear millwood, i do really thank you very much for reading the code and this explanation would be so useful :)

the code is fairly typical of a timer based approach to generate 50% duty cycle pulses
that was my big truble in this program. now i think it's more clear. i was reading about it in the last two days.

except that this particular piece of code isn't well written
yeah i got that. and it's hard for me to write such a program in assembly for PIC. i do know some basics only..
and that's why i'm using it :(


It isn't likely that you will understand the above if you have trouble understanding what a square wave is.
in the last replied for you. i told you my problem not in "understanding what a square wave is", it was in how to deal with P0.7. i got lost where to connect it. or maybe i could ignore/remove it...i though it could be an external ciruit connected to P0.7...:D i told you, i'm very beginner in this (not my field).
until my dear "rberek" explained it to me (many thanks to him).
and now, in ISIS the program runs Okey :) and the timer counting..
i'll upload/share the DSN file when i done with it ;) (for knowledge sharing), it could be helpful for some beginners.

Dear millwood, thanks for the C example, i can use too :)


hey dude. cool your self. forget all those post.
hi welove8051, i'm already coolllll ;)

just tell us what do u want. what is ur project concept.
actually, i'm working on RF project for 4G networks. and i need this timer to include it to manage my MIMO system.
the program runs fine now, thanks to rberek.


and why are u asking to delete this post, this post may be example for newbie's in what way they should not ask a question
yeah sure, even for me, it is a good example to be more clear and specific in my coming questions :D
thats how beginner's being, pal..
thanks for your post.
 

Some comments haven't been polite, but no justification for arrogance, I think.

useless talk..
i told you, i'm done in such talk.
so, please, if you can't help then keep silent.
thank you.
 

Some comments haven't been polite, but no justification for arrogance, I think.
let me tell you something, if you have something helpful related to this topic, so you are welcome and thanks.
otherwise, please, you keep silent too.

enough replies with useless, meaningless and helpless posts in here...
i did requested from admin to delete this topic because it has become a chaotic. and thanks to you, guys.
i hope you can learn something from "welove8051" and "rberek" first replies..

with all my respect for you, everybody.
 

enough replies with useless, meaningless and helpless posts in here...

wow, you managed to piss off so many people who tried their best to help you, in spite of all the obstacles you put up.

I think this may be why they invented phrases like "unappreciating @#$".
 

you managed to piss off so many people who tried their best to help you
dear millwood, i do really piss off no one. even you at the first reply of you.
and i did respond on each "unappreciating" post from you, guys.

i didn't came here LOOKING for YOUR HELP and then piss you off.

i do REALLY appreciate your help. you can count how many times i did thank you...
guys, you can compare any one of you (three guys) with Mr.rberek (especially with his first reply), then you will understand.
but non of you did/do that!!!! why?!
but just keeping replies with "useless, meaningless and helpless posts" in this topic!!! one goes another comes!!!

i do really have no bad feelings for anyone of you.

my respect and apology from you and everyone.
 

obviously, it is your life and you have every right to ruin it however you see fit.

people were just trying to provide you with suggestions hoping to bring you back to the right track, which clearly didn't work as you considered those attempts "useless, meaningless and helpless".

it is time to remind myself that everyone has the right to be stupid, :).

---------- Post added at 12:53 AM ---------- Previous post was at 12:50 AM ----------

i can use too :)

by that, you have suggested, without a doubt, that you don't understand the code and how the chip's timer works - as I planted a subtle bug in the code and you didn't spot it.

this goes back to the heart of the discussion: you don't understand what you are talking about. there is a reason that teaching mcu programming to a bunch of toddlers is going to be a disaster, regardless of how smart the said toddlers may be.
 

hey mill, please dont continue this mess no more. brilliant has got his output and he even apologized there is no point to continue any more. even i got this kind of rude replies as newbie( some other forum) and wondered why these members reply like that.

a experience person never makes mistakes, but experience come by making mistakes
 

The first reply brilliantelc got was this:

if this is representative of your knowledge, it is difficult to help you.

I think that whatever level of knowledge people have, these forums are for people to help, not criticise. If your only contribution is to patronize then don't reply.

It is often that problems are stated with insufficient clarity but there is no reason why further information cannot be requested in a polite way.

Once the level of expertise has been established it is possible to help everyone.

I have not replied to this thread before because I do not use the 8051 but given the lack of help brilliantelc has received I guess I should have tried to help before this thread got out of hand.

I find the attitude of some of the more experienced members of this forum appalling.

Keith
 
Once the level of expertise has been established it is possible to help everyone.

help comes in all shapes and forms. sometimes, not giving a hungry man a fish is the best help you can give that man.
 

I think the proverb is 'give a man a fish, you feed him for a day. Teach a man to fish, you feed a man for a lifetime.'

Where does 'if that's all you know about fish then you are beyond help...' fit in with that?

Keith
 
by that, you have suggested, without a doubt, that you don't understand the code and how the chip's timer works - as I planted a subtle bug in the code and you didn't spot it.
this goes back to the heart of the discussion: you don't understand what you are talking about. there is a reason that teaching mcu programming to a bunch of toddlers is going to be a disaster, regardless of how smart the said toddlers may be.
I will not reply on all what you said in that post..(ignore). Mr.welove8051 and keith1200rs are already answered that.
and let me tell you that i didn't read the C code you posted and never tested it.
i said "i can use it too :)" just as a complement for the info you had provided.
for a while, i really thought that you wanna help, but...opsss
however, you already proved for everybody here that you are ..SMART.. ;)
thats all what i can say, and no more mess.

help comes in all shapes and forms. sometimes, not giving a hungry man a fish is the best help you can give that man.
right, completely right.. but it depends on which case and in which style of response.
i suggest you to read carefully Mr.keith1200rs's post.

Dear welove8051
...and he even apologized there is no point to continue any more
true, i did. plus i did thanks him many times even without giving any help!!!
thats what made me reply on this mess!!!

..even i got this kind of rude replies as newbie( some other forum)...
Yes it is true that sometimes happens. But it's not (it's different) in this topic.
dear welove8051, with all my respect, it's seems that you didn't got the main point of this mess?!
Mr.keith1200rs is the only one here who got it right.
i already mentioned it many times in my replies. and did asked the guys to compare their first posts with Mr.rberek pointing to what Mr.keith1200rs has noticed.
but no one readssssss!

..and wondered why these members reply like that..
believe me dude, when the person show respect for others, they will response with respect too. specially in such a Forum where all fellow's here are educated people...
"We hurt others without even feel" and "We hurt ourselves when we hurt others"

"..a experience person never makes mistakes, but experience come by making mistakes.."


Dear welove8051, keith1200rs and Mr.rberek, guys, you are really entitled to be treated with FULL respect.
thank you.

Dear keith1200rs, really, you left no words to say :) you summarized all what i tried to say in all my relies in this topic.
you are the only one who pointed directly on the "central point" of this mess :D an "A" for you


i do really have no bad feelings for anyone of you.
my respect and apology from everyone.
repeated :)

---------- Post added at 06:52 PM ---------- Previous post was at 06:50 PM ----------

I think the proverb is 'give a man a fish, you feed him for a day. Teach a man to fish, you feed a man for a lifetime.'

Where does 'if that's all you know about fish then you are beyond help...' fit in with that?

Keith
it's seems that we all are going for "fishing" today :)))))
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top