Posted: Wed Sep 09, 2020 3:33 pm Post subject: Very simple frequency generator
Hello,
I found very simple frequency generator on Timer1 published by Arek2014 in "Share your working BASCOM-AVR code here" section.
What about Timer2?
Can we do similar thing using Timer2?
Timer1 is 16-bit and Timer2 is 8-bit so I would expect change in frequency range and resolution, this is not a problem.
Original code of Arek2014:
Code:
$crystal=8000000 ConfigTimer1=Timer , Prescale =1 ,cleartimer=1, Compare_a =Toggle'generator frequency!!! OC1A 'Ocr1a = 500 dim freq asword dim f asdword EnableInterrupts enabletimer1
do
f =4000000/ freq 'f crystal / 2 !!! print f ;"Hz"
Ocr1a = freq 'changing dim freq --> change frequency loop
My Code that generates frequency about 28kHz on OC2A output:
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