Click to See Complete Forum and Search --> : update...can anybody answer this? help on programming


hkboy313
October 25th, 2004, 01:59 AM
hi again..hopefully i am somewhere along the lines of 'close'

i wont tell the program objectives...but i made prg that works actually

but donno whatthe outputs mean... here is the program

#include <8051io.h>
#include <8051bit.h> /* Bit set/clear macros */
#include <8051reg.h>

void main()
{
int i;
serinit(9600);
asm
{
MOV TMOD,#10H
MOV TL1,#047H
MOV TH1,#0FFH
}
for(i=0; i<1; i++)
printf( "\nTimer=%d %d", TH1, TL1 );
}

the output is Timer=253 254


however if i change the timer to 0 which is TMOD,#01
and the printf( TH0, TL0); then i get this output Timer=255 71

can anybody explain what is this number mean? is it frequency? square wave signal? please help... thanks ...

bigBA
October 25th, 2004, 02:31 AM
well... a timer with microprocessor programming is (simply) a counter, which can (depends on the controller type) count up or downwards, with a desired (depends also on the controller type) frequency, often a multiple of the controllers frequency.
on overflow it will generate an interrupt, then you know, chosen time is over.

so i think (don't know anything about the 8051) that TL1 and TH1 are in fact the two halfs of the 16bit count register for the timer1.

so what your printf does is outputting the actual position of your timer.

its not a frequency, nor a square wave signal... its only the position of your counter.
example: if one count operation took 1 second and you want to wait 10 seconds. you set your timer register to 10 (if it counts downwards). if the register reaches 0, 10 seconds are over.

TSYS
October 25th, 2004, 08:10 AM
You'll have to explain what TMOD, TL1 and TH1 are. If I assume TL1 and TH1 are the low- and high-order bytes of a 16-bit word, then your first printed result, "253 254", corresponds to the 16-bit value FDFE, or -514. The second printed value, "255 71" corresponds to the 16-bit value FF47, or -185.

Who knows what these numbers mean? Your question provides no clues whatsoever.

hkboy313
October 25th, 2004, 12:55 PM
would you mind giving me an example of a square wave signal ? thank you again.

Andreas Masur
October 25th, 2004, 01:02 PM
[ Merged threads ]

bigBA
October 26th, 2004, 03:45 AM
what do you mean by "giving a example of a square wave signal"?

should i draw you a picture? *justjoking*

look at the other thread started by you... i gave an answer