![]() | ![]() | ![]() |
| |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
![]() |
| | Tools |
| | #1 |
|
How to calculate frequency of square wave with unknown frquency coming on P3.5 of 8051 controller in c? my effort is as follows.plz help by modifying it. i am not sure ,will the following program keep on counting or will calculate the pulses in one second..? #include <AT89X51.H> void msdelay(unsigned int); void main() { unsigned char value; T1=1; //make t1 an input TMOD=0x06; //counter 1,mode 2 ,8 bit auto reload mode TH1=0; //set count to 0 while(1) //repeat forever { do { TR1=1; //start timer value=TL1; //store tL1 in value P1=value; //place value on pins of p1 } while(TF1==0); //wait here TR1=0; //stop timer TF1=0; //clear flag } } void msdelay(unsigned int itime) { unsigned int i,j; for(i=0;i<itime;i++) for(j=0;j<1275;j++); } | |
| |
| | #2 |
|
Disclaimer first, I do not know anything about Amtel. However, I will do my best. You need to look up what "mode 2" means for the timer. Does it count up? Count down? The timer appears to be set to auto-reload, that probably means it will keep going after the first overflow (or underflow). It will output the value on the pins of p1 (port one?). However, I do not know what the delay will be. It does not appear that there is any delay in the timer steps, so it will probably run at full speed and count faster than you can see. The function msdelay() is never called, so it is quite redundant. Do not forget code tags around your program next time, it makes it easier to read. | |
| |
|
| Tags |
| humble, request, thankful |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| Hi! New here - and help request :) | Brianonymous | Electronic Projects Design/Ideas/Reviews | 3 | 7th December 2008 10:15 PM |
| A new request | Bryan76 | General Electronics Chat | 9 | 21st December 2006 05:30 AM |
| Request (please Help) | mos3ad | Datasheet/Parts Requests | 0 | 22nd June 2005 11:07 AM |
| request help | imgemini | Electronic Projects Design/Ideas/Reviews | 0 | 19th June 2004 10:04 PM |
| Request | marwahadhoud | Electronic Projects Design/Ideas/Reviews | 1 | 7th February 2004 12:53 AM |