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.

Help : Generate square wave...

Status
Not open for further replies.

kit_714

Member level 4
Joined
Jul 5, 2006
Messages
70
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
2,011
generate squarewave

Dear All,

I would like to ask which brand of MCU can generate 2MHz square wave by simply setting the port pin high and low alternatively?

If you all have other recommendations like using particular ICs, please send me the reference materials. Note that the square wave can not generated by using signal generator...

Many thanks....

Thanks and best regards,

Kit
 

how to generate a square wave in 8051?

Most AVRs with PWM can do that and I am sure PICs can also do that. If you have somthing without an internal PWM module then you simply toggle the pin. If you have nothing but a 89C51 microcontroller, just pick a version that runs at 24MHz and toggle the pin.

Like always don't overload your microcontroller pins. Also, if all you need is a stable 2Mhz oscillator, you can configure a CMOS version of 555 for stable outputs. Or can simply use a TTL oscillator for 2Mhz. All you have to do is just provide the supply and your 2MHz will start comming out in perfect precision. You can easily get TTL oscillators with 4 digit precisions like 2.0000 MHz.

**broken link removed**
**broken link removed**
The TTL oscillator will be something like this, http://www.parallax.com/detail.asp?product_id=252-00005

If you want variable clock frequencies you can consider VCO's which stands for voltage controller oscillator.

Correction: A standard 8051 microcontroller must operate in excess of 48MHz to generator a 2MHz square wave. IIRC, there is somemode that can make some 8051 controllers to execute in 6-phases instead of 12 in which case you can use a 24MHz controller.
 

generate square wave cmos

For 2MHz.. a dsPIC or even better a 16 bit Renesas or ARM is suited...

But I would like to stand corrected.
 

8051 microcontroller, square waves

vsmGuy said:
For 2MHz.. a dsPIC or even better a 16 bit Renesas or ARM is suited...

But I would like to stand corrected.

Talk about overkill. Even the tinyAVR series from ATMEL boast super high clock frequencies in 10s of MHz range and cost less than a dollar.
 

microcontroller generate square wave

It depends!
If accuracy is desired, an MCU with PWM (50%-50% duty) may be a better choice.
If accuracy is not so important, a fast MCU (e.g. 40MHz or higher) may be used by
toggling the IO port.
 

tinyavr signal generator

waterman said:
It depends!
If accuracy is desired, an MCU with PWM (50%-50% duty) may be a better choice.
If accuracy is not so important, a fast MCU (e.g. 40MHz or higher) may be used by
toggling the IO port.

I beg to differ, the reason I am advocating so strongly is that I've done this and done it many times before. I used everything from simple RC oscillators to VCXOs, function generator ICs, PWMs etc etc. The speed of the microcontroller to choose depends on the microcontroller not some fixed value multiplied by the required frequency. For example:

AVR and PIC, which are RISC, can execute most instructions in a signle cycle. So theoratically speaking a 4MHz AVR/PIC can do that job.
 

generate a square wave of 50% duty 8051

Using PIC Calc (link on my site)
2MHz 50% duty can be generated in hardware at 16MHz on any PIC with a CCP module.
 

generate square wave

sorry, but if you need help setting a pin high and low at 2MHz, you're in the wrong business.
 

atmel generate square waves

jhbbunch said:
sorry, but if you need help setting a pin high and low at 2MHz, you're in the wrong business.

Everyone's a beginner at sometime or the other. After all the purpose of these forums is to help each other out and act as a place for discussions.
 

12f629 square wavw generator

If the only job of the MCU is to generate the square wave, a low-speed MCU could be used.

If the MCU has to do something else besides generatig the square wave, a low-speed MCU may not be suitable to do this job.

Consider this: 2MHz --> period = 500ns --> low/high interval = 250ns.

For a 12T 8051, SET/CLR the IO port needs 1 instruction cycle. That is, 250ns to execute an instruction. Then the system clock should be 48MHz and the 8051 does not have spare time to do anything else.

For a RISC like PIC16/PIC18, 4T for one instruction, the system clock my be lower. However, 16MHz is still needed.

If AVR is used, one clock for one instruction. However, 4MHz is still needed for operation.

Any comment is welcome.
 

To bit-bang an I/O pin at 2 MHz continuously, you also need a jump instruction somewhere.
Or do some microcontrollers provide zero-overhead looping?

Code:
loop: set output bit high
      nop
      set output bit low
      jump loop
That would require an 8 MHz clock for 2 MHz output, assuming one instruction per clock.

It would be nicer to simply configure a counter/timer or PWM, if available.
 

The 16F628 yes, 12F629 yes, but 12F628?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top