View previous topic :: View next topic |
Author |
Message |
jocaropi
Joined: 25 Jun 2014 Posts: 18
|
SPI2 pin select not working |
Posted: Mon Sep 29, 2014 7:43 am |
|
|
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
|
|
Posted: Mon Sep 29, 2014 9:14 am |
|
|
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
|
|
Posted: Mon Sep 29, 2014 9:27 am |
|
|
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
|
|
Posted: Mon Sep 29, 2014 11:17 am |
|
|
The second should certainly work. However it'll use software SPI. So what happens?. |
|
|
jocaropi
Joined: 25 Jun 2014 Posts: 18
|
|
Posted: Mon Sep 29, 2014 11:48 am |
|
|
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
|
|
Posted: Thu Jul 23, 2015 6:21 am |
|
|
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
|
|
Posted: Thu Jul 23, 2015 7:13 am |
|
|
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. |
|
|
|