Jinzpaul4u
Full Member level 4
- Joined
- Feb 1, 2012
- Messages
- 231
- Helped
- 59
- Reputation
- 118
- Reaction score
- 60
- Trophy points
- 1,328
- Location
- India
- 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
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: