| CodeGuru Home | VC++ / MFC / C++ | .NET / C# | Visual Basic | Newsletters | VB Forums | Developer.com |
|
|||||||
| Assembly Questions and Answers for Assembly here! |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
update...can anybody answer this? help on programming
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 ... |
|
#2
|
||||
|
||||
|
Re: maybe c++ people can help me? i posted in assembly too...
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.
__________________
there are 10 kinds of people. those who understand binary and those who don't... rate a post if you find it usefull, thx check out my Firefox/Mozilla Extension: http://urlparams.blogwart.com/ |
|
#3
|
|||
|
|||
|
Re: maybe c++ people can help me? i posted in assembly too...
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.
__________________
Regards Robert Thompson |
|
#4
|
|||
|
|||
|
Re: maybe c++ people can help me? i posted in assembly too...
would you mind giving me an example of a square wave signal ? thank you again.
|
|
#5
|
|||
|
|||
|
Re: update...can anybody answer this? help on programming
[ Merged threads ]
__________________
Ciao, Andreas "Software is like sex, it's better when it's free." - Linus Torvalds Article(s): Allocators (STL) Function Objects (STL) |
|
#6
|
||||
|
||||
|
Re: update...can anybody answer this? help on programming
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
__________________
there are 10 kinds of people. those who understand binary and those who don't... rate a post if you find it usefull, thx check out my Firefox/Mozilla Extension: http://urlparams.blogwart.com/ |
![]() |
| Bookmarks |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|