Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Simplest Freq/Duty generator an measure

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here
View previous topic :: View next topic  
Author Message
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 971

poland.gif
PostPosted: Wed May 22, 2019 2:52 pm    Post subject: Simplest Freq/Duty generator an measure Reply with quote

I really don know why I dont post this simplest method for generate desired square wave.
I was think that this is already shared so maybe Im belated...

This two codes and schematics enable to generate square wave you want by entering it with keypad..and second code is "complementary" Very Happy It measure but only in designed spectrum.
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5920
Location: Holland

blank.gif
PostPosted: Wed May 22, 2019 8:22 pm    Post subject: Reply with quote

Thanks for sharing Very Happy
_________________
Mark
Back to top
View user's profile Visit poster's website
Arek2014

Bascom Member



Joined: 30 Dec 2014
Posts: 22
Location: Kielce

poland.gif
PostPosted: Wed Sep 25, 2019 8:56 pm    Post subject: Reply with quote

Simple generator Smile

Code:
$crystal = 8000000
Config Timer1 = Timer , Prescale = 1 ,clear timer = 1, Compare_a = Toggle    'generator frequency!!! OC1A
'Ocr1a = 500
dim freq as word
dim f as dword
Enable Interrupts
enable timer1

do
f = 4000000 / freq  'f crystal / 2 !!!
print f ; "Hz"
Ocr1a = freq    'changing dim freq --> change frequency
loop
Back to top
View user's profile
Pzx

Bascom Member



Joined: 05 May 2015
Posts: 39

poland.gif
PostPosted: Wed Sep 09, 2020 3:04 pm    Post subject: Reply with quote

Arek, thanks for your simple generatr code.
What about Timer2?
OCR2A doesnt work.
Can you do the same with Timer2?
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum