External Toggle

External Toggle
8051 micro controller Help needed?

include “mpi.h”

void Init_Device(void); // an external function prototype

sbit at 0×96 led1; // Port 1 (SFR 0×90) bit 6
sbit at 0×97 led2; // Port 1 (SFR 0×90) bit 7

void main ( void ) {
Init_Device(); // VERY IMPORTANT
tmr2Init(4); // keep time in 4 ms resolution
led1 = 0;
led2 = 1;
while(1) {
led1 = !led1; // Read back, toggle value, write back
led2 = !led2;
tmr2DlySet(500);
while (!tmr2DlyExpired()) { // while NOT …
// can do other task here
}
}
}

from this program we can see that the Delay is at 500ms….but what i want is to make the delay at 0.5ms…..how do i write the codes to do that??

0.5 ms is a VERY short time. I doubt that 8051 supports such frequencies. I suggest that you replace the line with

tmr2DlySet(500)

to:

tmr2DlySet(1)

And see where that takes ya. Also, I couldn’t find the documentation to tmr2DlySet() function. Post the source code here, if you can, then I might give you a better answer.

NOTE: The reason I doubt that you can go less than 1 ms, is that, for micro controller to support such frequency it has to run its clock in nano-seconds, which is very unlikely.

Kershaw ET External Toggle Serrated Knife 1900ST Demonstration


You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Comments are closed.