November 23, 2024, 12:46:28 AM

PIC WEB AN Trimmer help

Started by Trgrant, December 19, 2012, 02:23:35 PM

Previous topic - Next topic

Trgrant

Hello all,
    I'm a beginner programmer, using the PICWEB Rev.C.  I am trying to use the onboard trimmer to control the duty cycle for PWM being outputted through ECCP1.  I am fairly sure my code is correct except I can't seem to get the code to read the trimmer value.  I can post my code later today if needed but if I could get some info on how to use the trimmer value for anything that would be appreciated.

Trgrant

Here is my code, just trying to use the onboard pot to alter the output voltage to an external led.  Please help.
#include <p18f67j60.h>
#pragma config WDT = OFF
#pragma config FOSC = HSPLL
#pragma config XINST = OFF
#define LED TRISCbits.TRISC2
#define Trimmer PORTFbits.RF3


void main (void)
{

   
    int TrimmerPercent;
int a, b, c = 0;
TRISF = 0x08;

a = Trimmer;
b = 100;
c = a * b;
TrimmerPercent = c;

LED = 0;
T2CON = 0b00000111;
PR2 = 100;
CCP1CON = 0x0C;

while(1)
{
CCPR1L = TrimmerPercent;

}
}