Hardware Routines 

Click on a routine name to see the source

ReadADC(channel as ubyte) 
            Reads ADC channel channel, and returns a 16 bit right-justified result.

Requires the following #defines: 
#DEFINE ADC_DELAY 15 (optional - aquisition delay in usec)
#DEFINE ADC_CLOCK 3  (to select the clock source) 

HPWM(channel, freq, duty_cycle, output_config, output_polarity)
   
     Generates a PWM signal using the hardware PWM module. 

Parameters: 

Channel           -  the desired CCP channel (1 or 2) 

Freq                 - the frequency in hertz desired for the output. Note that there are minimum frequencies that can be used, depending on the oscillator frequency being used. Check the data sheets. For example, at 20 mHz, the min freq is 1221 Hz 

duty_cycle        -the on/off ratio of the output waveform. It ranges from 0 to 1023, the on fraction being “duty_cycle/1024” 

The following are only used on PICs with the enhanced PWM module. Check the PIC documentation for details. 

Output_config     - 0,1,2,3: single-ended, full-bridge forward, half-bridge, full-bridge reverse 

Output_polarity   - 0,1,2,3: 0 is active high for the single-ended output, 2 is active low