Subversion Repositories Code-Repo

Rev

Rev 122 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 122 Rev 123
Line 28... Line 28...
28
    LATBbits.LATB5 = 0;
28
    LATBbits.LATB5 = 0;
29
 
29
 
30
    SSP2STATbits.SMP = 0; // Input is sampled in the middle of data output time
30
    SSP2STATbits.SMP = 0; // Input is sampled in the middle of data output time
31
    SSP2STATbits.CKE = 0; // Transmit occurs on transition from Idle to active clock state
31
    SSP2STATbits.CKE = 0; // Transmit occurs on transition from Idle to active clock state
32
 
32
 
-
 
33
    SSP2CON1bits.SSPM = speed;
33
    if (speed == SPI2_FOSC_4)
34
//    if (speed == SPI2_FOSC_4)
34
        SSP2CON1bits.SSPM = 0b0000; // Clock = FOSC/4
35
//        SSP2CON1bits.SSPM = 0b0000; // Clock = FOSC/4
35
    else if (speed == SPI2_FOSC_8)
36
//    else if (speed == SPI2_FOSC_8)
36
        SSP2CON1bits.SSPM = 0b1010; // Clock = FOSC/8
37
//        SSP2CON1bits.SSPM = 0b1010; // Clock = FOSC/8
37
    else if (speed == SPI2_FOSC_16)
38
//    else if (speed == SPI2_FOSC_16)
38
        SSP2CON1bits.SSPM = 0b0001; // Clock = FOSC/16
39
//        SSP2CON1bits.SSPM = 0b0001; // Clock = FOSC/16
39
    else
40
//    else
40
        SSP2CON1bits.SSPM = 0b0010; // Clock = FOSC/64
41
//        SSP2CON1bits.SSPM = 0b0010; // Clock = FOSC/64
41
 
42
 
42
    SSP2CON1bits.CKP = 1; // Idle state for clock is a high level
43
    SSP2CON1bits.CKP = 1; // Idle state for clock is a high level
43
    SSP2CON1bits.SSPEN = 1; // Enable MSSP module
44
    SSP2CON1bits.SSPEN = 1; // Enable MSSP module
44
 
45
 
45
#ifdef SPI2_USE_INTERRUPT
46
#ifdef SPI2_USE_INTERRUPT