Hi Guys
I’m trying to map pins associated with SPI1 to pins RP6-RP9 for use with an SD Card library,
but so far I don’t think I’ve gotten past mapping the SPI peripheral.
The controller is dsPic33FJ128GP802.
My PPS.h file has an include file in it for some other processor, and the include file for that device doesn’t exist,
so I don’t get to use PPS.h to do it the easy way:
So what I think I need to do instead is something like this:
but after that, I don’t see any activity on an LED connected to the SPIDO port when the SD card is accessed,
and the file system initialise routine fails (returns false).
Furthermore, just using the lines that adjust OSCCON (without the pin remapping code) has an effect on some
of my display routines that those pins should have nothing to do with, so they either interfere with other pins on portB,
or interfere with some variables or arrays involved in the display routines.
Can anyone see any obvious mistake?
Cheers, Brek.
I’m trying to map pins associated with SPI1 to pins RP6-RP9 for use with an SD Card library,
but so far I don’t think I’ve gotten past mapping the SPI peripheral.
The controller is dsPic33FJ128GP802.
My PPS.h file has an include file in it for some other processor, and the include file for that device doesn’t exist,
so I don’t get to use PPS.h to do it the easy way:
Code:
PPSUnLock;
PPSInput(PPS_SDI1, PPS_RP6); //Sets RP6 (pin 15) to be Input, and maps to SPI IN
PPSOutput(PPS_SS1, PPS_RP9);//Sets RP9 (pin 18) to be Output, and maps to SPI CS
PPSOutput(PPS_SCK1, PPS_RP8);//Sets RP8 (pin 17) to be Output, and maps to SPI CLK
PPSOutput(PPS_SDO1, PPS_RP7);//Sets RP7 (pin 16) to be Output, and maps to SPI OUT
PPSLock;
}
Code:
// PPS needs to first unlock the pins before re-assignment
__builtin_write_OSCCONL(0x46); // unlock sequence - step 1
__builtin_write_OSCCONH(0x57); // unlock sequence - step 2
_IOLOCK = 0;
// Pins can now change - though, these don't change in the SFR debugger window... why?
_RP8R = 8; // configure sck1 as output
_RP7R = 7; // configure sdo1 as output
_RP9R = 9; // configure ss1 as output
RPINR20bits.SDI1R = 6; // configure SDI for input
__builtin_write_OSCCONL(0x46); // unlock sequence - step 1
__builtin_write_OSCCONH(0x57); // unlock sequence - step 2
_IOLOCK = 1; // re-lock the ports
and the file system initialise routine fails (returns false).
Furthermore, just using the lines that adjust OSCCON (without the pin remapping code) has an effect on some
of my display routines that those pins should have nothing to do with, so they either interfere with other pins on portB,
or interfere with some variables or arrays involved in the display routines.
Can anyone see any obvious mistake?
Cheers, Brek.