CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Compilation error in SPI MODE 3 and MODE 0

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
GAGAN



Joined: 10 Aug 2016
Posts: 9

View user's profile Send private message Send e-mail

Compilation error in SPI MODE 3 and MODE 0
PostPosted: Wed Aug 17, 2016 10:26 pm     Reply with quote

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 ); Rolling Eyes
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Thu Aug 18, 2016 1:50 am     Reply with quote

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: 19520

View user's profile Send private message

PostPosted: Thu Aug 18, 2016 2:56 am     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Thu Aug 18, 2016 6:28 am     Reply with quote

Thank you for your feedback.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group