Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

ECCP3 captured module on pic18f97j60

Status
Not open for further replies.

lakis

New Member
Hi guys .I'm trying to modify the program that i find in here
https://sites.google.com/site/ehutonline/home/pic-microcontroller/C18-Libraries-Examples/input-c

so it can work on pic18f97j60 using the ECCP3 because it is the only one available .

but i get this Errors and warnings
C:\Users\lakis\Desktop\ECCP\test.c:58:Error [1105] symbol 'EC3_EVERY_FALL_EDGE' has not been defined
C:\Users\lakis\Desktop\ECCP\test.c:58:Warning [2058] call of function without prototype
C:\Users\lakis\Desktop\ECCP\test.c:76:Warning [2058] call of function without prototype
C:\Users\lakis\Desktop\ECCP\test.c:80:Error [1105] symbol 'EC3_EVERY_RISE_EDGE' has not been defined
C:\Users\lakis\Desktop\ECCP\test.c:80:Warning [2058] call of function without prototype
C:\Users\lakis\Desktop\ECCP\test.c:96:Warning [2058] call of function without prototype
C:\Users\lakis\Desktop\ECCP\test.c:122:Error [1105] symbol 'EC3_EVERY_RISE_EDGE' has not been defined
C:\Users\lakis\Desktop\ECCP\test.c:124:Warning [2058] call of function without prototype
C:\Users\lakis\Desktop\ECCP\test.c:165:Warning [2058] call of function without prototype

that is my code until now
Code:
#include<p18f97j60.h>// Include files and definitions for the Processor

#include<capture.h>//Include function definitions for the Capture library

#include<timers.h>// Include function definitions for Timer Library

#include<stdlib.h>// Include function definitions for string manupulation Library


#pragma config WDT=OFF// 
#pragma config DEBUG = ON 
#pragma config XINST= OFF
 #pragma config  FOSC=HS


unsigned int result,hightime,totaltime,dutycycle;//Variables used

unsigned char start=1;

unsigned char highlow,end;

char str[5];

void Send(void);// Function for sending data to serial port

void chk_isr(void);// ISR Handler

void hi_prioriint(void)// ISR Routine

{

                _asm

                GOTO chk_isr

                _endasm

}

#pragma interrupt chk_isr

void chk_isr(void)

{

                if(PIR3bits.CCP3IF)

                               {

                                                if(start==1)

                                                {

                                                                WriteTimer1(00);//Start timer 1 for maximum count

                                                                OpenECapture3( CAPTURE_INT_ON & //Initialize CCP for HtoL

                                                                                                                  EC3_EVERY_FALL_EDGE );

                                                                start=0;

                                                                highlow=1;

                                                                PIR3bits.CCP3IF=0;// Enable interrupt again

                                                }

                                                else

                                                {

                                                                if(highlow==1)

                                                                {

                                                                                hightime = ReadECapture3();// Read contents of capture registers

                                                                                OpenCaEpture3( CAPTURE_INT_ON & //Initialize CCP for LtoH

                                                                                                                               	EC3_EVERY_RISE_EDGE  );

                                                                                highlow=0;

                                                                                end=1;

                                                                                PIR3bits.CCP3IF=0;

                                                                }

                                                                else

                                                                if(end==1)

                                                                {

                                                                                totaltime=ReadECapture3();// Read contents of Capture registers

                                                                                CloseTimer1();// Close timer 1

                                                                                Send();// Send the measured time values to the serial port

                                                                }

                                                }

                                }

}

void main(void)

{

                //OSCCON=0x60;//Internal 4MHz oscillator

                ADCON1=0x7f;//Make all  pins Digital

                               

                //Initiazlize the capture moudule(ccp) for LtoH  

                OpenECapture3( EC3_EVERY_RISE_EDGE

                                                                                & CAPTURE_INT_ON  );

               

                OpenTimer1( TIMER_INT_OFF &//configure Timer1 for ccp

                                                                T1_16BIT_RW &// Can also use Timer3

                                                                T1_SOURCE_INT & // Timer1 clock source is internal

                                                                T12_SOURCE_CCP &// Make Timer1 source for CCP module

                                                                T1_PS_1_1);// No prescaler for timer1

               

                //Initialize USART for tx  high time,total time

               

                                                   INTCONbits.GIEH=1;// Enable all interrupts
                 

                while(1);// wait here

}

 

void Send(void)// For sending the times

{

             

                ultoa(hightime,str);// convert integer in to string

               

                ultoa(totaltime,str);// convert integer in to string

             CloseECapture3();// 
               INTCONbits.GIE=0;//Disbale interrupts

                while(1);// wait here

}

does any one no how to solve that problem.
 
thank you for answer
I'm using Mplab ide v8.63 student edition
what is the ECCP header and where can i found it
 
Where is the documentation for your compiler.... What IS your compiler? Did you download the code from another site?

Looking at the version I have. The "capture header" is the correct header, but openEcapture3() isn't listed... this chip isn't in my version ( I may need an update ) I have version mplabc18 version 3.40..
 
Last edited:
No it isn't ! openEcapture1() or opencapture3(), but not openEcapture3()!! as there is only ONE ECCP then it will be openEcapture1() you need to use.

Also change EC3_EVERY_FALL_EDGE to EC1_EVERY_FALL_EDGE.
 
Last edited:
i can't use ECCP1 on my pic18f because is used for other thinks
But i have try to change to EC1_EVERY_FALL_EDGE and then i get

ECAP_EVERY_FALL_ EDGE has not has not been defined

and i don't now if that what mean for the captured. h file
those are parts from captured.h file
Code:
#if defined (ECC_V8) || defined (ECC_V8_1) 
#ifndef USE_OR_MASKS
//***************** ECCP source - TIMER selection ********************************************
//*************ECCP1**************
#define ECCP_1_SEL_TMR12		    0b10001111  	//ECCP selects TIMER1 for Capture & Compare and TIMER2 for PWM
#define ECCP_1_SEL_TMR34		    0b10011111  	//ECCP selects TIMER3 for Capture & Compare and TIMER4 for PWM
#define ECCP_1_SEL_TMR36		    0b10101111  	//ECCP selects TIMER3 for Capture & Compare and TIMER6 for PWM
#define ECCP_1_SEL_TMR38		    0b10111111  	//ECCP selects TIMER3 for Capture & Compare and TIMER8 for PWM
#if defined (ECC_V8)
#define ECCP_1_SEL_TMR310		    0b11001111  	//ECCP selects TIMER3 for Capture & Compare and TIMER10 for PWM
#define ECCP_1_SEL_TMR312		    0b11011111  	//ECCP selects TIMER3 for Capture & Compare and TIMER12 for PWM
#endif

//*************ECCP2**************
#define ECCP_2_SEL_TMR12		    0b10001111  	//ECCP selects TIMER1 for Capture & Compare and TIMER2 for PWM
#define ECCP_2_SEL_TMR34		    0b10011111  	//ECCP selects TIMER3 for Capture & Compare and TIMER4 for PWM
#define ECCP_2_SEL_TMR36		    0b10101111  	//ECCP selects TIMER3 for Capture & Compare and TIMER6 for PWM
#define ECCP_2_SEL_TMR38		    0b10111111  	//ECCP selects TIMER3 for Capture & Compare and TIMER8 for PWM
#if defined (ECC_V8)
#define ECCP_2_SEL_TMR310		    0b11001111  	//ECCP selects TIMER3 for Capture & Compare and TIMER10 for PWM
#endif

//*************ECCP3**************
#define ECCP_3_SEL_TMR12		    0b11001111  	//ECCP selects TIMER1 for Capture & Compare and TIMER2 for PWM
#define ECCP_3_SEL_TMR34		    0b11011111  	//ECCP selects TIMER3 for Capture & Compare and TIMER4 for PWM
#define ECCP_3_SEL_TMR36		    0b11101111  	//ECCP selects TIMER3 for Capture & Compare and TIMER6 for PWM
#define ECCP_3_SEL_TMR38		    0b11111111  	//ECCP selects TIMER3 for Capture & Compare and TIMER8 for PWM

void OpenECapture1 ( unsigned char config);
unsigned int ReadECapture1 (void);
void CloseECapture1 (void);

#if defined (ECC_V8) || defined (ECC_V8_1)
void OpenECapture2 ( unsigned char config);
unsigned int ReadECapture2 (void);
void CloseECapture2 (void);

void OpenECapture3 ( unsigned char config);
unsigned int ReadECapture3 (void);
void CloseECapture3 (void);
#endif
 
i can't use ECCP1 on my pic18f because is used for other thinks
But i have try to change to EC1_EVERY_FALL_EDGE and then i get

ECAP_EVERY_FALL_ EDGE has not has not been defined

and i don't now if that what mean for the captured. h file
those are parts from captured.h file
Code:
#if defined (ECC_V8) || defined (ECC_V8_1) 
#ifndef USE_OR_MASKS
//***************** ECCP source - TIMER selection ********************************************
//*************ECCP1**************
#define ECCP_1_SEL_TMR12		    0b10001111  	//ECCP selects TIMER1 for Capture & Compare and TIMER2 for PWM
#define ECCP_1_SEL_TMR34		    0b10011111  	//ECCP selects TIMER3 for Capture & Compare and TIMER4 for PWM
#define ECCP_1_SEL_TMR36		    0b10101111  	//ECCP selects TIMER3 for Capture & Compare and TIMER6 for PWM
#define ECCP_1_SEL_TMR38		    0b10111111  	//ECCP selects TIMER3 for Capture & Compare and TIMER8 for PWM
#if defined (ECC_V8)
#define ECCP_1_SEL_TMR310		    0b11001111  	//ECCP selects TIMER3 for Capture & Compare and TIMER10 for PWM
#define ECCP_1_SEL_TMR312		    0b11011111  	//ECCP selects TIMER3 for Capture & Compare and TIMER12 for PWM
#endif

//*************ECCP2**************
#define ECCP_2_SEL_TMR12		    0b10001111  	//ECCP selects TIMER1 for Capture & Compare and TIMER2 for PWM
#define ECCP_2_SEL_TMR34		    0b10011111  	//ECCP selects TIMER3 for Capture & Compare and TIMER4 for PWM
#define ECCP_2_SEL_TMR36		    0b10101111  	//ECCP selects TIMER3 for Capture & Compare and TIMER6 for PWM
#define ECCP_2_SEL_TMR38		    0b10111111  	//ECCP selects TIMER3 for Capture & Compare and TIMER8 for PWM
#if defined (ECC_V8)
#define ECCP_2_SEL_TMR310		    0b11001111  	//ECCP selects TIMER3 for Capture & Compare and TIMER10 for PWM
#endif

//*************ECCP3**************
#define ECCP_3_SEL_TMR12		    0b11001111  	//ECCP selects TIMER1 for Capture & Compare and TIMER2 for PWM
#define ECCP_3_SEL_TMR34		    0b11011111  	//ECCP selects TIMER3 for Capture & Compare and TIMER4 for PWM
#define ECCP_3_SEL_TMR36		    0b11101111  	//ECCP selects TIMER3 for Capture & Compare and TIMER6 for PWM
#define ECCP_3_SEL_TMR38		    0b11111111  	//ECCP selects TIMER3 for Capture & Compare and TIMER8 for PWM

void OpenECapture1 ( unsigned char config);
unsigned int ReadECapture1 (void);
void CloseECapture1 (void);

#if defined (ECC_V8) || defined (ECC_V8_1)
void OpenECapture2 ( unsigned char config);
unsigned int ReadECapture2 (void);
void CloseECapture2 (void);

void OpenECapture3 ( unsigned char config);
unsigned int ReadECapture3 (void);
void CloseECapture3 (void);
#endif
 
sorry i was going write that you mean that even i'm going to use the pin with the ECCP3 mode i'm still using the ECCP1 mode?
then openEcapturede3 should i change it to openEcaptured1?

I'm sorry for the miss-understanding but it is the first time i'm using this mode and the second time i'm working with micro controller ?
 
I'm learning this as we go along as well.... The documentation is VERY contradictory The "MPLAB C18 library" pdf and the corresponding HTML file say different things.

The chip you are using ALL the modules can be used as Enhanced for capture compare.... I don't think the compiler supports any more than 1.

Weird
 
yes i agree about what you said for c18 library

i change the the program to
OpenECapture3( CAPTURE_INT_ON & EC1_EVERY_FALL_EDGE );

i copy from captured.h file the*
#define ECAP_EVERY_FALL_EDGE 0b10000100 / Capture on every falling edge*/
#define ECAP_EVERY_RISE_EDGE 0b10000101

now i'm not getting the EC3_ EVERY_FALL_EDGE Error but i
get
Error - could not find definition of symbol 'OpenCaEpture3' in file './test.o'.

i'm have all the warnings
 
i have already try that then i get
Error - could not find definition of symbol 'ReadECapture1' in file './test.o'.
i can't understand why
 
i haven't exactly understand this mean that i can't use ECCP for capture mode with the pic18f97j60
and that instead openEcapture3 i should set opencapture3

where have you find this. if it's a web page send me the link
 
if your installation is in "C:\MCC18\" Then look in the "doc" folder then the "periph lib" he pictures posted are from there... The last one is from V3.4 the very latest that is in the microchip directory. But I don't think you have that one...
 
Ian Rogers thank you for your all help
that was the problem
this it my code now
Code:
#include<p18f97j60.h>// Include files and definitions for the Processor

#include<capture.h>//Include function definitions for the Capture library

#include<timers.h>// Include function definitions for Timer Library


#include<stdlib.h>// Include function definitions for string manupulation Library

#pragma config WDT=OFF// 
#pragma config DEBUG = ON 
#pragma config XINST= OFF
 #pragma config  FOSC=HS

unsigned int result,hightime,totaltime,dutycycle;//Variables used

unsigned char start=1;

unsigned char highlow,end;

char str[5];

void Send(void);// Function for sending data to serial port

void chk_isr(void);// ISR Handler

void hi_prioriint(void)// ISR Routine

{

                _asm

                GOTO chk_isr

                _endasm

}

#pragma interrupt chk_isr

void chk_isr(void)

{

                if(PIR3bits.CCP3IF)

                                {

                                                if(start==1)

                                                {

                                                                WriteTimer1(00);//Start timer 1 for maximum count

                                                                OpenCapture3( CAPTURE_INT_ON & //Initialize CCP for HtoL

                                                                                                                  C3_EVERY_FALL_EDGE );

                                                                start=0;

                                                                highlow=1;

                                                                PIR3bits.CCP3IF=0;// Enable interrupt again

                                                }

                                                else

                                                {

                                                                if(highlow==1)

                                                                {

                                                                                hightime = ReadCapture3();// Read contents of capture registers

                                                                                OpenCapture3( CAPTURE_INT_ON & //Initialize CCP for LtoH

                                                                                                                                C3_EVERY_RISE_EDGE );

                                                                                highlow=0;

                                                                                end=1;

                                                                                PIR3bits.CCP3IF=0;

                                                                }

                                                                else

                                                                if(end==1)

                                                                {

                                                                                totaltime=ReadCapture3();// Read contents of Capture registers

                                                                                CloseTimer3();// Close timer 1

                                                                                Send();// Send the measured time values to the serial port

                                                                }

                                                }

                                }

}

void main(void)

{

                //OSCCON=0x60;//Internal 4MHz oscillator

                ADCON1=0x7f;//Make all  pins Digital

                               

                //Initiazlize the capture moudule(ccp) for LtoH  

                OpenCapture3( C3_EVERY_RISE_EDGE

                                                                                & CAPTURE_INT_ON  );

               

                OpenTimer1( TIMER_INT_OFF &//configure Timer1 for ccp

                                                                T1_16BIT_RW &// Can also use Timer3

                                                                T1_SOURCE_INT & // Timer1 clock source is internal

                                                                T12_SOURCE_CCP &// Make Timer1 source for CCP module

                                                                T1_PS_1_1);// No prescaler for timer1

               

                //Initialize USART for tx  high time,total time

               

                                                   INTCONbits.GIEH=1;// Enable all interrupts
                 

                while(1);// wait here

}

 

void Send(void)// For sending the times

{

             

                ultoa(hightime,str);// convert integer in to string

               

                ultoa(totaltime,str);// convert integer in to string

             

                CloseCapture1();// Close CCP Module

                INTCONbits.GIE=0;//Disbale interrupts

                while(1);// wait here

}
BUILD SUCCEEDED

thanks again.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top