hkboy313
October 24th, 2004, 12:08 AM
i am a noob ...im taking an embedded class and i have a lab that wants me to generate a square wave signal...well i got the time period which is 200 microsec. and 50% duty cycle is 100 microsec. crystal freq is 22.183 with that i got FF47 for the value (I think) that will go into the timer register.
with that given...and that i calculated...i programmed something at least...
#include <8051io.h>
#include <8051bit.h> /* Bit set/clear macros */
#include <8051reg.h>
void main()
{
serinit(9600);
asm
{
MOV TMOD,#01
HERE: MOV TL0,#047H
MOV TH0,#0FFH
CPL P1.5
ACALL DELAY
SJMP HERE
DELAY:
SETB TR0
AGAIN: JNB TF0, AGAIN
CLR TR0
CLR TF0
RET
}
}
i know its kinda stupid to do that but...i saw an example on the program i used...micro-ide ...u can find the 8051 program at www.bipom.com butu need the hardware stuff to download program. i cannot compile this bcause i think of the asm language inside that prg.
well my question is if im on the right track or total lost.... or in the asm above do i have to have the input in binary with "#%"? this is really confusing..its not even in our book! "The 8051 Microcontroller and embedded system" by muhammad ali mazidi and anice mazidi...
sorry for long explanations...just had a couple concerns i wanted to get helped on.
thanks so much in advance...
with that given...and that i calculated...i programmed something at least...
#include <8051io.h>
#include <8051bit.h> /* Bit set/clear macros */
#include <8051reg.h>
void main()
{
serinit(9600);
asm
{
MOV TMOD,#01
HERE: MOV TL0,#047H
MOV TH0,#0FFH
CPL P1.5
ACALL DELAY
SJMP HERE
DELAY:
SETB TR0
AGAIN: JNB TF0, AGAIN
CLR TR0
CLR TF0
RET
}
}
i know its kinda stupid to do that but...i saw an example on the program i used...micro-ide ...u can find the 8051 program at www.bipom.com butu need the hardware stuff to download program. i cannot compile this bcause i think of the asm language inside that prg.
well my question is if im on the right track or total lost.... or in the asm above do i have to have the input in binary with "#%"? this is really confusing..its not even in our book! "The 8051 Microcontroller and embedded system" by muhammad ali mazidi and anice mazidi...
sorry for long explanations...just had a couple concerns i wanted to get helped on.
thanks so much in advance...