Quantcast
Channel: MCS Electronics Forum
Viewing all articles
Browse latest Browse all 20696

BASCOM-AVR : Adc and pwm : REPLY

$
0
0
Hi to all Forum members As I said I want to generate the frequency of 31.25 Khz and have write the following code, I have not used the ADC yet as I want to fixup the PWm thing first, but I am getting the frequency of 3.911 kHz what could be the problem. '------------------------------------------------------------------------------ 'name : Buck Regulator.bas 'copyright : (c) 2013, NaseerAK 'purpose : Buck Converter 'micro : Mega8 'suited for demo : ? 'commercial addon needed : no '------------------------------------------------------------------------------ $regfile = "m8def.dat" ' we use the M8 $crystal = 8000000 $baud = 19200 $hwstack = 32 $swstack = 8 $framesize = 24 $regfile = "m8.dat" ' specify the used micro $crystal = 8000000 ' used crystal frequency $baud = 19200 ' use baud rate $hwstack = 32 ' default use 32 for the hardware stack $swstack = 10 ' default use 10 for the SW stack $framesize = 40 Config Adc = Single , Prescaler = Auto , Reference = Avcc 'Now give power to the chip Start Adc Config Timer1 = Pwm , Pwm = 10 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down , Prescale = 9 Dim W As Word , Channel As Byte Do Pwm1a = 512 'this should result in 50% duty cycle Pwm1b = 256 'this should result in 25% duty cycle Loop End Thanks and regards

Viewing all articles
Browse latest Browse all 20696


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>