Pic18f6722 spi.h and open spi1 problem

Thread Starter

Picbuster

Joined Dec 2, 2013
1,059
When using pic18f8722 or pic18f87k22 spi.h will be found (many of my application are using this)
and OpenSPI1(SPI_FOSC_64, MODE_11, SMPMID); works

Following the manual and procedures to set the pic
However ; pic18f6722 or pic18f67k22 fails.

I am able to find spi.h using the list but compiler/linker can't find it so OpenSPI1(SPI_FOSC_64, MODE_11, SMPMID); can't work.
But it does find SPI_FOSC_64 MODE_11 SMPMID
pic18f8722 and pic6722 (picF18 family) should be compatible and are printed on same datasheet.

I do not use mcc that's a pain and not working correctly.

I build my own SPI drivers but want to use Microchips spi.h
Does any body know how to solve this problem?

Your help will be appriciated.

Regards,
Picbuster
 

nsaspook

Joined Aug 27, 2009
16,330
When using pic18f8722 or pic18f87k22 spi.h will be found (many of my application are using this)
and OpenSPI1(SPI_FOSC_64, MODE_11, SMPMID); works

Following the manual and procedures to set the pic
However ; pic18f6722 or pic18f67k22 fails.

I am able to find spi.h using the list but compiler/linker can't find it so OpenSPI1(SPI_FOSC_64, MODE_11, SMPMID); can't work.
But it does find SPI_FOSC_64 MODE_11 SMPMID
pic18f8722 and pic6722 (picF18 family) should be compatible and are printed on same datasheet.

I do not use mcc that's a pain and not working correctly.

I build my own SPI drivers but want to use Microchips spi.h
Does any body know how to solve this problem?

Your help will be appriciated.

Regards,
Picbuster
Confused about what software you are using. Is it C18 based or XC8?
 

nsaspook

Joined Aug 27, 2009
16,330
Hi Nsaspook,

I am using xc8 and all compilers from 1.34 to 2.xx producing this error.

Picbuster
Can you post/link a short program source/project that shows the problem. Sounds like more of a linker file issue. I have some 8722 board project code but it's old C18 based.
 

Thread Starter

Picbuster

Joined Dec 2, 2013
1,059
Hi,
Here relevant collection
#pragma config CCP2MX=0, WDTPS=8192, XINST=OFF,FCMEN=OFF,CCP2MX=0, IESO=OFF,
TRISC =0b00100000;
SSP1CON1bits.SSPEN1=1; // enable Spi1

#include <spi.h> //<== found and working for pic18f8722 pic18f87k22.

//found spi.h for pic18f6722 or pic18f67k22 but produced an error.
//Main.c:15:16: error: (141) can't open include file "spi.h": No such file or directory
// but spi.h was selected from include list table!! so it did exist.
// next step copy spi.h to source dir and load it same problem.
// you could be correct with you linker issue remark.

SSP1STAT= 0b1000000;
SSP1CON1bits.CKP=0;
SSP1CON1bits.SSPM=1; // 0=/4 1=/16 2=/64
PIE1bits.SSP1IE=0; // no int yet


OpenSPI1(SPI_FOSC_64, MODE_11, SMPMID); // error (open will set/overwrite SSPICON1bits )

while (1)
{
ReadRtc();
}

Picbuster
 

trebla

Joined Jun 29, 2019
599
#include <spi.h>
This includes file from compilers preinstalled path, if you use #include "spi.h" then it looks this file in the project root directory.

EDIT:
Maybe you must copy also SPI source files to your project directory or include with absolute path, it depends how you are updated compilers, PLIB does'nt always work as expected on my different machines.
 
Last edited:

Thread Starter

Picbuster

Joined Dec 2, 2013
1,059
This includes file from compilers preinstalled path, if you use #include "spi.h" then it looks this file in the project root directory.

EDIT:
Maybe you must copy also SPI source files to your project directory or include with absolute path, it depends how you are updated compilers, PLIB does'nt always work as expected on my different machines.
Dear Treba,
I do agree your remark about PLIB .
I already moved the spi.h to my project dir no effect.
It seems to be a compiler issue as stated by nsaspook.

Picbuster
 

trebla

Joined Jun 29, 2019
599
In my old project support machine PLIB libraries exists only with xc8 1.41 and 1.43 installation. Better to make copy for .h an .c files and add to project directory and add libray paths. The pconfig.h file is also needed.
 
Top