[51] how to code a program to generate 10khz squar wave using microcontroller-8051 crystal

Status
Not open for further replies.

Murugappan.pl

Newbie level 2
Joined
Apr 30, 2015
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
12
how to code a program to generate 10khz squar wave using microcontroller-8051 crystal?as i am beignner help me
 

Assuming you have your compiler and linker already set up to compile/build and upload the code and you don't need much. Once you are in the main function, set up the output pin (i.e. via the direction register) and toggle it after a delay of 100us.

A much better way is to use hardware timers, which allow you to configure a couple registers to generate the square wave without using CPU resources.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…