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

SPI mode change

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



Joined: 28 Mar 2020
Posts: 5
Location: York, PA

View user's profile Send private message

SPI mode change
PostPosted: Tue Mar 30, 2021 1:43 pm     Reply with quote

I am working with a PIC18F67K22 microcontroller, using the PCWH compiler ver 5.093.
I have a working SPI bus configured as follows:

#use spi (MASTER, SPI1, BAUD=500000, MODE=0, BITS=8, STREAM=SPI_1)

The bus is operational with all spi devices except for one that requires the MODE=1 (IDLE=0 and SAMPLE_FALL). I have not found a library function that can change modes within the program (when communicating with the particular device).

Is there any way, besides using assembly (#asm.....#endasm)?

Thanks!
GusA



Joined: 28 Mar 2020
Posts: 5
Location: York, PA

View user's profile Send private message

PostPosted: Tue Mar 30, 2021 2:29 pm     Reply with quote

CCS technical support replied as follows, which BTW I tried and worked fine:

You can do this:

#use spi (MASTER, SPI1, BAUD=100000, MODE=0, BITS=8, STREAM=SPI_1A) #use spi (MASTER, SPI1, BAUD=100000, MODE=1, BITS=8, STREAM=SPI_1B)

Call spi_init() to change the mode and always use the right stream ID for the SPI calls.
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Tue Mar 30, 2021 11:31 pm     Reply with quote

Yes, this has been answered here before. Using two (or more) streams. Very Happy
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