Hi i have spent the last few hour's trying to get PWM to work on my pic18f16k22. Im using the C18 compiler in MPLABX V6.1 The probolem im having is it compiles with this error
Error - could not find definition of symbol 'SetDCPWM1' in file './build/default/production/_ext/916313547/PWM.o'.
Errors : 1
The PWM.h file definatly contains the definition and is included in my config.
I started off wrighting my own code then found several examples on the web and thay all compile with this error
My last code looks like this using some code from a C18 cheat sheet by AtomSoftTech.
Thank you for taking time to read my post.
Error - could not find definition of symbol 'SetDCPWM1' in file './build/default/production/_ext/916313547/PWM.o'.
Errors : 1
The PWM.h file definatly contains the definition and is included in my config.
Rich (BB code):
void SetDCPWM1 ( unsigned int duty_cycle);
My last code looks like this using some code from a C18 cheat sheet by AtomSoftTech.
Rich (BB code):
#include <p18Cxxx.h>
#include <pwm.h>
#include <delays.h>
#pragma config FOSC = INTIO67 // Oscillator Selection
#pragma config WDTEN = OFF // Watchdog Timer
#pragma config MCLRE = INTMCLR // MCLR Pin Enable bit
#pragma config DEBUG = ON // Background Debug
#define PWM_Tris TRISCbits.TRISC2 //Define a nice name for the PWM TRIS bit.
char direction; //direction holder for out loop
void main (void)
{
char DutyCyc = 0x66; //Start Duty Cycle
OSCCON = 0x72; //8MHz clock
while(!OSCCONbits.IOFS); //Wait for OSC to become stable
PWM_Tris = 0; //Set the pin a OUTPUT
SetOutputPWM1 (SINGLE_OUT, PWM_MODE_1); //Set as single output pwm and mode 1 (P1A,P1B,P1C,P1D active-high)
OpenPWM1(DutyCyc); //Set the duty cycle and start the PWM module
while(1){
if(DutyCyc == 0x12) //Check if we reached our minimum. If so set direction (up)
direction = 1;
if(DutyCyc == 0x66) //Check if we reached our maximum. If so clear direction (down)
direction = 0;
SetDCPWM1(DutyCyc); //Set the new duty cycle
if(direction == 1) //based on direction if 1 (up) add 2 each time to the duty cycle
DutyCyc+=2;
else // if 0 (down) minus 2 each time to the duty cycle
DutyCyc-=2;
Delay10KTCYx(3); //small delay (15mS)
}
}