View previous topic :: View next topic |
Author |
Message |
GAGAN
Joined: 10 Aug 2016 Posts: 9
|
Compilation error in SPI MODE 3 and MODE 0 |
Posted: Wed Aug 17, 2016 10:26 pm |
|
|
Hi, am using PIC24HJ series and trying to implement SPI interface in my application.
Iam finding a problem while compiling a code which specifies as UNIDENFIED IDENTIFIER SPI_XMIT_L_TO_H
i want SPI in MODE3 but compiler works properly only when am using MODE 1 and MODE 2 but for MODE 0 and MODE 3 am getting compilation error...
below is my SPI setup function(In-built function)...
setup_spi(SPI_MASTER | SPI_H_TO_L | SPI_XMIT_L_TO_H | SPI_CLK_DIV_4 ); |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Thu Aug 18, 2016 1:50 am |
|
|
Honestly, much easier to just use #use spi, and the mode number.
What chip?.
The reason though is that the SPI is very different on the PIC24. You must always look at the .h for _your_ processor, to see what options are allowed. If you look at the data sheet for the chip, you will find that the PIC24, does not have a control bit called SPI_XMIT_L_TO_H any more. Instead it has a CKE bit (clock edge). Now normally CCS give 'SPI_XMIT_L_TO_H' for compatibility, but it sounds as if this may be missing for your chip. Hence the need to tell us what chip is involved?.
A quick glance through the .h files for PIC24HJ chips, does not show any with the define missing. You are including the file for your chip?.
The normal syntax for a PIC24, would be:
setup_spi(SPI_MASTER | SPI_SCK_IDLE_HIGH | SPI_XMIT_L_TO_H | SPI_CLK_DIV_4 | SPI_SAMPLE_AT_MIDDLE | SPI_MODE_8B)
to give an 8bit SPI.
However:
#USE SPI(SPI1, MODE=3, bits=8, baud=whatyouwant, STREAM=SPI_1)
then use spi_xfer for your transmission/reception. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Thu Aug 18, 2016 2:56 am |
|
|
I'd suspect you have a truly antique compiler.
Just searched back, and when some HJ chips were added in the mid 4.0xx compiler, they lacked all the SPI defines. By 4.11x, the defines were complete.
Honestly if your compiler is this old, you will have other problems with chips like the HJ.... |
|
|
GAGAN
Joined: 10 Aug 2016 Posts: 9
|
|
Posted: Thu Aug 18, 2016 6:28 am |
|
|
Thank you for your feedback. |
|
|
|