Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC18f46J50 SPI2 code

Status
Not open for further replies.

Jinzpaul4u

Full Member level 4
Full Member level 4
Joined
Feb 1, 2012
Messages
231
Helped
59
Reputation
118
Reaction score
60
Trophy points
1,328
Location
India
Visit site
Activity points
2,822
Hi there,

I have been working on pic18f46j50 with 2nd spi module. I remapped spi2 pins using Remappable peripheral module.

null SPI_init(null)
{
ODCON3=0x01; //Initialize ODCON3 register (optional open-drain output control) for SPI1.
PPSInput(PPS_SDI2, PPS_RP23); //SDIpin in RD6
PPSOutput(PPS_RP19, PPS_SDO2); // SDO pin in RD2
PPSOutput(PPS_RP21, PPS_SCK2); // SCK pin in RD4
PPSLock();

TRISDbits.TRISD2 = 0; // SDO2 pin is ouput type
TRISDbits.TRISD6 = 1; // SDI2 pin is input type
TRISDbits.TRISD4 = 0; // SCK2 pin is ouput type
TRISAbits.TRISA5 = 0; // SS2 pin is ouput type
SSP1STAT =0b00000000;
SSP1CON1 =0b00100000;//SPI Clock = FOSC/4
__SPI_STOP;
}



But unfortunately my code ain't working. Does anyone know, what mistake I had done?

P.S: mplab, c18 compiler

I have attached my code here,View attachment SPI_MAIN.txt

Any kind of feedback would be appreciable,

Thanks
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top