Almost everyone who replied to you asked: "what you want to do with this code?" (please reread previous answers).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!!!
;SQUARE WAVE GENERATION ROUTINE
TMR0_INIT: MOV TL0,#0F0H
MOV TH0,#0DBH
SETB IE.7 ;iNTRUPPUT ENABLE
SETB IE.1
MOV TMOD,#01H ;
NOP
NOP
SETB TCON.4 ; SET TR1
RET
;*************************
TIMER0: CLR TCON.4 ; CLEAR TR1
CPL P0.7 ; COMPLEMENT P0.7
MOV TL0,#0F0H
MOV TH0,#0D0H
SETB TCON.4
RETI
//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) {
}
}
wow, you are so smart. congratulations.ust take a look at the way characters are written in the memory buffer/LCD, not mentioning other parts of the code!
useless talk.....To me this is unpoliteness.
Dear millwood, i do really thank you very much for reading the code and this explanation would be so usefulI don't code in assembly but if you have read the datasheet, the code wouldn't be difficult for you to read....
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.the code is fairly typical of a timer based approach to generate 50% duty cycle pulses
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..except that this particular piece of code isn't well written
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...It isn't likely that you will understand the above if you have trouble understanding what a square wave is.
hi welove8051, i'm already coolllllhey dude. cool your self. forget all those post.
actually, i'm working on RF project for 4G networks. and i need this timer to include it to manage my MIMO system.just tell us what do u want. what is ur project concept.
yeah sure, even for me, it is a good example to be more clear and specific in my coming questionsand 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
useless talk..
i told you, i'm done in such talk.
so, please, if you can't help then keep silent.
thank you.
let me tell you something, if you have something helpful related to this topic, so you are welcome and thanks.Some comments haven't been polite, but no justification for arrogance, I think.
enough replies with useless, meaningless and helpless posts in here...
dear millwood, i do really piss off no one. even you at the first reply of you.you managed to piss off so many people who tried their best to help you
i can use too
if this is representative of your knowledge, it is difficult to help you.
Once the level of expertise has been established it is possible to help everyone.
I will not reply on all what you said in that post..(ignore). Mr.welove8051 and keith1200rs are already answered that.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.
right, completely right.. but it depends on which case and in which style of response.help comes in all shapes and forms. sometimes, not giving a hungry man a fish is the best help you can give that man.
true, i did. plus i did thanks him many times even without giving any help!!!...and he even apologized there is no point to continue any more
Yes it is true that sometimes happens. But it's not (it's different) in this topic...even i got this kind of rude replies as newbie( some other forum)...
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.....and wondered why these members reply like that..
repeatedi do really have no bad feelings for anyone of you.
my respect and apology from everyone.
it's seems that we all are going for "fishing" todayI 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
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?