Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how to generate EXACT 40 kHz wave using AT89S51 having 24 MHz crystal ..?

Status
Not open for further replies.

saurabheda

Junior Member level 3
Joined
Oct 16, 2011
Messages
25
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,460
actually the problem arises when we use timer of microcontroller to have a delay of 12.5 µs (half of 25 µs {time period equivalent to 40 kHz})
, it becomes comparable to time spent by the µC in executing instructions ( 0.5 µs for 1 Machine Cycled instructions) and hence the instructions to produce the delay contribute significantly to the delay..
how to get EXACT 40 kHz in this scenario then..?? please help....
 

at the end of the delay of timer , you will execute certain instructions to change the port bit.
after changing , you will start again the timer.

count the execution time of this two and subtract it fro the count value and reload it in timer and start.

repeat this for every change in state of output bit.
 

dear srizbf.. i am writing the code in C.. how again then i can get the exact time consuming in the instructions you mentioned....

Actually i have to actuate a 40 kHz ultrasonic transmitter using this signal..so precise wave is necessaary..
 

exact timing like this can not be done in pure C.
you may have to use 'in line asm' in C code.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top