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 a 2 MHz pulse with 30% duty cycle using PICbasic.

Status
Not open for further replies.

wyiancwc88

Newbie level 4
Joined
Aug 14, 2010
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,318
I am using PIC 16F877A with 20MHz crystal. I am wondering can it generate a 2MHz clock pulse with 30-40% duty cycle. Can anyone help me on this?
 

First calculate the time period, t=1/f.
Then for 30% multiply time period with .03, t*.03.
Similarly for 40% multiply time period with .04, t*.04.
Then load this value into the timer reg.

Note: you should know the instruction execution time. For example in 877 with 4MHz crystal value of timer will increment after 1us.(if using internal clock)
 

Actually I'm new to PIC and I am not really know how it operates, so can you provide me the source code? Thx a lot.
 

I have a few questions here:

1. Is every instruction cycle= crystal freq/4?
2. If crystal = 20Mhz, a single instruction cycle = 5Mhz or 0.2us right?
3. I wan to generate a 2MHz pulse wave with 30% duty cycle.. Can i just send HIGH to a port and then LOW it?

just like this,


_______ _______
| 30% |______70%_______| |_____________

|-150ns-| ------350ns------ |


begin:
high 0 'send HIGH to portB.0
pause 150 'delay for 150ms (writing like this,the delay is in ms,but I want it in ns)
low 0 'send LOW to portB.0
pause 350 'delay for 350ms
goto begin 'repeat

end

pause, for delay of milisecond
pauseus, for delay of microsecone

My problem is, how to make it delay in ns instead of ms and us? Is there any alternative to make a delay in ns?
 
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top