Hello Friends,
Started learning SPI. Trying 8-bit transfer from PIC (Master ) to a microcontroller(Slave).
MCC code generated and flashed on device. Tried to see the Clock(RC3 pin ), data on SDI(RC4 pin) and SDO(RC5 pin) lines using oscilloscope. FOSC is 16MHZ. Clock rate set as FOSC/4. Able to see clock at RC3 pin but frequency is different shown on oscilloscope. Also not seeing data on SDO and SDI lines. I generated correct MCC code.
When I debug using Real ICE, I can see SSPBF while sent is getting A1, and receiving B9 in the below code. Slave is selected.
PIN INITIALIZATION, OSCILLATOR INITIALIZATION has been done by MCC.
Let me know why data is not traceable on SDO, SDI, lines.
--David.
Moderator edit: added code tags.
Started learning SPI. Trying 8-bit transfer from PIC (Master ) to a microcontroller(Slave).
MCC code generated and flashed on device. Tried to see the Clock(RC3 pin ), data on SDI(RC4 pin) and SDO(RC5 pin) lines using oscilloscope. FOSC is 16MHZ. Clock rate set as FOSC/4. Able to see clock at RC3 pin but frequency is different shown on oscilloscope. Also not seeing data on SDO and SDI lines. I generated correct MCC code.
When I debug using Real ICE, I can see SSPBF while sent is getting A1, and receiving B9 in the below code. Slave is selected.
Code:
uint8_t SPI_Exchange8bit(uint8_t data)
{
// Clear the Write Collision flag, to allow writing
SSPCON1bits.WCOL = 0;
SSPBUF = data; //Send Data A1
while(SSPSTATbits.BF == SPI_RX_IN_PROGRESS)
{
}
return (SSPBUF); //Received B9
}
void SPI_Initialize(void)
{
// Set the SPI module to the options selected in the User Interface
// R_nW write_noTX; P stopbit_notdetected; S startbit_notdetected; BF RCinprocess_TXcomplete; SMP Middle; UA dontupdate; CKE Idle to Active; D_nA lastbyte_address;
SSPSTAT = 0x00;
// SSPEN enabled; WCOL no_collision; CKP Idle:Low, Active:High; SSPM0 FOSC/4; SSPOV no_overflow;
SSPCON1 = 0x20;
// SSPADD 0;
SSPADD = 0x00;
}
Let me know why data is not traceable on SDO, SDI, lines.
--David.
Moderator edit: added code tags.