Re: Dual PWM's using 12F683? Failure, Suggestions?
OK I got it to work using a 12F1572. I wanted to post my code and see if anyone can spot something I need to clean up or rework. please note a small problem i ran into noted after code. DEFINE OSC 4 DEFINE ADC_BITS 8 ' A/D number of bits DEFINE ADC_CLOCK 1 ' Use A/D internal RC clock DEFINE ADC_SAMPLEUS 50 ' Set sampling time in us 50 ADCON0.7 = 0 ' Justify Result to 10 & 8 bit Side RES1 Var byte ' A/D converter result RES0 VAR BYTE AGAIN: ADCIN 2, Res0 ' Read Channel 3 data ADCIN 3, Res1 ' Read Channel 3 data if res1 < 10 then res1 = 0 ' Low Auto Shutoff if res0 < 10 then res0 = 0 ' Low Auto Shutoff HPWM 2, res0, 10000 ' PWM Pin, Setting, Frequency (20k Max) HPWM 1, res1, 10000 ' PWM Pin, Setting, Frequency (20k Max) pause 5 goto again ----------------- sorry not in code block, my page doesnt show those options. ok the problem i ran into is that the 12f1572 is supposed to be capable of running up to 32mhz using internal clock I thought it read. however if i change the define to 32, then it slowwwws way down, also even when set to 4mhz i had to make my pause at the end 5, where it used to be 100 with older chips? any ideas on how i can specify a higher internal clock freq, and why i have to use such a low pause (if i use a 100 my leds flash, with a 5 they change fairly smoothly.)
Chris
Any man who has accomplished anything in electronics at one time or another has said... " STOP! WAIT! NOOO! Dangit.... Oh Well, Time to start over..."
Bookmarks