eng.hasan.power
Member level 1
hi everyone,
im facing a problem, im tryin to connect DSP with the 97j60, ethernet, by SPI,
the controller is slave, in Interrupt mode, im using the functions of C18 compiler
OpenSPI1(SLV_SSOFF, MODE_00, SMPEND);
the problem is,,,,,,the DSP sending the data, i check it by signal analyzer,
but the j60 dont receive it correctly,,,,,and even dont go for the interrupt routine in the first place,,,,,
the j60 sees the signal at the Clk pin,,,,but it doesnt go to the interrupt routine,
here is the configuration, its the standard from C18 compiler, but i added some lines,
OpenSPI1(SLV_SSOFF, MODE_00, SMPEND); //hasan
void OpenSPI1( unsigned char sync_mode, unsigned char bus_mode, unsigned char smp_phase)
{
SSP1STAT &= 0x3F; // power on state
SSP1CON1 = 0x00; // power on state
SSP1CON1 |= sync_mode; // select serial mode
SSP1STAT |= smp_phase; // select data input sample phase
switch( bus_mode )
{
case 0: // SPI1 bus mode 0,0
SSP1STATbits.CKE = 1; // data transmitted on rising edge
break;
case 2: // SPI1 bus mode 1,0
SSP1STATbits.CKE = 1; // data transmitted on falling edge
SSP1CON1bits.CKP = 1; // clock idle state high
break;
case 3: // SPI1 bus mode 1,1
SSP1CON1bits.CKP = 1; // clock idle state high
break;
default: // default SPI1 bus mode 0,1
break;
}
switch( sync_mode )
{
case 4: // slave mode w /SS enable
// #if defined SPI_IO_V1
// TRISCbits.TRISC3 = 1; // define clock pin as input
// TRISAbits.TRISA5 = 1; // define /SS1 pin as input
// #elif defined SPI_IO_V2
TRISFbits.TRISF7 = 0; // define /SS1 pin as Output //hasan 97j60
PORTFbits.SS1 = 1;
TRISCbits.TRISC3 = 1; // define clock pin as input
// #endif
break;
case 5: // slave mode w/o /SS enable
TRISCbits.TRISC3 = 1; // define clock pin as input
break;
default: // master mode, define clock pin as output
TRISCbits.TRISC3 = 0; // define clock pin as input
break;
}
TRISCbits.TRISC4 = 1; // define SDI pin as input
TRISCbits.TRISC5 = 0; // define SDO pin as output
SSP1CON1 |= SSPENB; // enable synchronous serial port
INTCONbits.GIE = 0 ;
INTCONbits.GIE = 1 ;
RCONbits.IPEN = 1; // Enable Interrupts
INTCONbits.GIEH = 1;
INTCONbits.GIEL = 1;
PIE1bits.SSP1IE = 0 ;
PIE1bits.SSP1IE = 1 ; //Hasan
}
#endif
#################################
the Hardware connection is directly,,,, I/p SDI<->O/p SDO,,,, ,,, Clk<->Clk,,,,
thank you in advance,,,,,,
im facing a problem, im tryin to connect DSP with the 97j60, ethernet, by SPI,
the controller is slave, in Interrupt mode, im using the functions of C18 compiler
OpenSPI1(SLV_SSOFF, MODE_00, SMPEND);
the problem is,,,,,,the DSP sending the data, i check it by signal analyzer,
but the j60 dont receive it correctly,,,,,and even dont go for the interrupt routine in the first place,,,,,
the j60 sees the signal at the Clk pin,,,,but it doesnt go to the interrupt routine,
here is the configuration, its the standard from C18 compiler, but i added some lines,
OpenSPI1(SLV_SSOFF, MODE_00, SMPEND); //hasan
void OpenSPI1( unsigned char sync_mode, unsigned char bus_mode, unsigned char smp_phase)
{
SSP1STAT &= 0x3F; // power on state
SSP1CON1 = 0x00; // power on state
SSP1CON1 |= sync_mode; // select serial mode
SSP1STAT |= smp_phase; // select data input sample phase
switch( bus_mode )
{
case 0: // SPI1 bus mode 0,0
SSP1STATbits.CKE = 1; // data transmitted on rising edge
break;
case 2: // SPI1 bus mode 1,0
SSP1STATbits.CKE = 1; // data transmitted on falling edge
SSP1CON1bits.CKP = 1; // clock idle state high
break;
case 3: // SPI1 bus mode 1,1
SSP1CON1bits.CKP = 1; // clock idle state high
break;
default: // default SPI1 bus mode 0,1
break;
}
switch( sync_mode )
{
case 4: // slave mode w /SS enable
// #if defined SPI_IO_V1
// TRISCbits.TRISC3 = 1; // define clock pin as input
// TRISAbits.TRISA5 = 1; // define /SS1 pin as input
// #elif defined SPI_IO_V2
TRISFbits.TRISF7 = 0; // define /SS1 pin as Output //hasan 97j60
PORTFbits.SS1 = 1;
TRISCbits.TRISC3 = 1; // define clock pin as input
// #endif
break;
case 5: // slave mode w/o /SS enable
TRISCbits.TRISC3 = 1; // define clock pin as input
break;
default: // master mode, define clock pin as output
TRISCbits.TRISC3 = 0; // define clock pin as input
break;
}
TRISCbits.TRISC4 = 1; // define SDI pin as input
TRISCbits.TRISC5 = 0; // define SDO pin as output
SSP1CON1 |= SSPENB; // enable synchronous serial port
INTCONbits.GIE = 0 ;
INTCONbits.GIE = 1 ;
RCONbits.IPEN = 1; // Enable Interrupts
INTCONbits.GIEH = 1;
INTCONbits.GIEL = 1;
PIE1bits.SSP1IE = 0 ;
PIE1bits.SSP1IE = 1 ; //Hasan
}
#endif
#################################
the Hardware connection is directly,,,, I/p SDI<->O/p SDO,,,, ,,, Clk<->Clk,,,,
thank you in advance,,,,,,