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 can i create square wave signal in C?

Status
Not open for further replies.

ash

Full Member level 3
Joined
Dec 25, 2002
Messages
151
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,298
Location
Europe
Activity points
1,051
How can i create square wave signal in C for pic micros?

Regards.
 

Hi,

it's so easy
for example to creat 1khz square wave using ccs c compiler.

We calcualte time duration T=1/1000Hz = 1 ms
Then divide it by 2 ---> 1ms/2 = 500 us

while (1) {
output_high(PIN_A1);
delay_us(500);
output_low(PIN_A1);
delay_us(500);

}

Bye
 

Also, many controllers have timers with PWM output. Then you have to program timer to generate PWM with 50% duty cycle and frequency 1kHz....
 

You can use PWM or timer to create square wave ,it may just frequency your need. :)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top