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

SPI2 pin select not working

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



Joined: 25 Jun 2014
Posts: 18

View user's profile Send private message

SPI2 pin select not working
PostPosted: Mon Sep 29, 2014 7:43 am     Reply with quote

Hello, I'm programming a PIC33EP512GP502 with the CCS v5.025.
I need to use the external interrupt 0 (INT0) and the SPI communication at the same time, but the INT0 and the SCK1 functions share the same PIN.
So I'm trying to use the SPI2 and remap it somewhere else, but it doesn't work.
Here is my code:

Code:
#pin_select SCK2OUT=PIN_B9
#pin_select SDO2=PIN_B8
#use spi(MASTER, SPI2, MODE=0, BITS=8, stream=SPI_PORT2)


I have tried many things, but anything works, could someone help me please?

Thank you in advance.
Ttelmah



Joined: 11 Mar 2010
Posts: 19548

View user's profile Send private message

PostPosted: Mon Sep 29, 2014 9:14 am     Reply with quote

Try configuring the SDI2 pin.

'Output only', is not a legal SPI setup for the chip.

Look at the data sheet:
"The SPIx module can be configured to operate with
two, three or four pins. In 3-pin mode, SSx is not used.
In 2-pin mode, neither SDOx nor SSx is used."

Note that the only 'two pin only' mode is input only, not output only.

You don't have to read the input, so provided you use a pin that is an input, it shouldn't matter. The compiler may be getting confused because of this (worth a try...).
jocaropi



Joined: 25 Jun 2014
Posts: 18

View user's profile Send private message

PostPosted: Mon Sep 29, 2014 9:27 am     Reply with quote

Thank you for your reply.
I have tried:
Code:
#pin_select SCK2OUT=PIN_B9
#pin_select SDI2=PIN_B6
#pin_select SDO2=PIN_B8
#use spi(MASTER, SPI2, MODE=0, BITS=8, stream=SPI_PORT1)

and also:
Code:
#use spi(DI=PIN_B6, DO=PIN_B8, CLK=PIN_B9, BITS=8)

Anything works :/
Ttelmah



Joined: 11 Mar 2010
Posts: 19548

View user's profile Send private message

PostPosted: Mon Sep 29, 2014 11:17 am     Reply with quote

The second should certainly work. However it'll use software SPI. So what happens?.
jocaropi



Joined: 25 Jun 2014
Posts: 18

View user's profile Send private message

PostPosted: Mon Sep 29, 2014 11:48 am     Reply with quote

I don't know, I'm driving a lcd display with SPI. SPI1 works, so I know the code for the display is correct. It just doesn't communicate.
tinley



Joined: 09 May 2006
Posts: 67

View user's profile Send private message Visit poster's website

PostPosted: Thu Jul 23, 2015 6:21 am     Reply with quote

I just found this thread because I had the same issue with a 33EP256MU806 using CCS version 5.021

I just found I can't select pins for SPI2, but SPI3 works. Since I only need two SPI channels I will leave it at this for now.

But does anyone know if the compiler bug is sorted now please? Maybe time to update?
Ttelmah



Joined: 11 Mar 2010
Posts: 19548

View user's profile Send private message

PostPosted: Thu Jul 23, 2015 7:13 am     Reply with quote

The key is that CCS used lots of 'undocumented' pin names. The names being used didn't match what was in the manual. Some were 'found', by people looking through the program files. This was moaned about to CCS a few weeks ago, and the latest compiler versions now have a nice table at the start of the include file for each processor listing the relocatable pin names, and the peripheral.

However your problem is not the same, and is not a compiler problem. Check the data sheet for your chip....

Start of section 18:

"Four SPI modules are provided on a single device.
These modules, which are designated as SPI1, SPI2,
SPI3 and SPI4, are functionally identical with the exception
that SPI2 is not remappable
. The dedicated SDI2,
SDO2 and SCK2 connections provide improved performance
over SPI1, SPI3 and SPI4 (see Section 32.0
“Electrical Characteristics”)."

SPI2, is _not_ remappable.....

The compiler can only do what the chip supports.
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