Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

freqout on multiple pins

Status
Not open for further replies.

cybersky

Member
Hi
I am trying to use the freqout function as a tone generator. but i want to do polyphonic sounds. Is it possible to get freqout on multiple pins ?
 
Hi
I am trying to use the freqout function as a tone generator. but i want to do polyphonic sounds. Is it possible to get freqout on multiple pins ?

hi,
It will only output the Freq square wave on the PORT pin that appears first in the program sequence

So
FreqOut PORTB.0, 600, 1000 ;would be the active pin
FreqOut PORTB.1, 1000, 1000; will be LOW
 
You could do it but not with FreqOut. You would have to write your own code. Say you need 50Hz and 60Hz then you would generate a loop at 300Hz and count 5 for the 60Hz signal and 6 for the 50Hz signal.

Assuming your using an 8 MHz clock then you can use timer2 to contol your loop. Setting Timer2 to prescaler 16, postscaller 1 and PR2 equal to 208 would give a 300Hz (600 time per second) loop by just testing PIR1.TMR2IF at the start of it. Remember to clear it as well.

The above is just an illustration and the actual frequencies required will decide if it's possible.

Mike.
 
Hi
Thanks for link languer. I guess sometimes we become too dependent on the built-in functions. I do prfer oshonsoft to the other basic ide's. But a little extra coding never hurt either. Thanks all for the suggestions.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top