Hello all. I'm a newbie and I wrote a small program with PicBasic Pro to test on my MikroElektronica development board (very nice.) It is a simple pulse width/frequency controller running on a 16f877A.
I would like it to run on a 12f683 for a different application (actually all I need is the Pulse width part - the frequency will be set,) but reading over the data sheet for the 12f683 makes me feel like I've been drugged with some kind of horse barbiturate.

I don't get how to set the register properly for this function or to select input pins. Would some nice person out there who knows a bit about the 12f683 take a peek (pun intended) at this and tell me what I need to change to make it function? (It works great on the 16f877A)

Oh yeah, one more thing. I have the ADC set to use the internal clock (because it's the only way I could get it to work,) but am actually using a 20Mhz crystal. Is this OK or should I set the ADC_Clock number to something else? This I also could not decipher from the data sheet. That number seems to change from PIC model to model. How the heck does one figure out what number to use?

Thanks in advance.

Here is the program:

DEFINE ADC_BITS 8
DEFINE ADC_CLOCK 3 'Uses internal RC clock
DEFINE ADC_SAMPLEUS 50 'Microsecond sample time

'Variables
PulseWidth VAR BYTE
Freqtmp VAR BYTE
Frequency VAR Word
TRISA = 255 ' Set PORTA to all input
ADCON1 = 2 ' PORTA is analog

Loop:
'Read Input Variables
ADCIN 2, PulseWidth 'Read channel 2 to variable "PulseWidth" PinA.2
ADCIN 3, Freqtmp 'Read channel 3 to variable "Freqtmp" PinA.3
Frequency = Freqtmp * 100 'Make Freq = 0-25,500hz in 100hz intervals


'Send Pulse
HPWM 1, PulseWidth, Frequency 'Send PWM with variable Duty and Frequency PinC.2 on 16f677A

Pause 500
goto Loop 'Do it forever


Regards,
Chris Helvey
Being a beginner can be so frustrating....