Datasheet

2011-2013 Microchip Technology Inc. DS39995D-page 163
PIC24FV32KA304 FAMILY
To set up the SPI1 module for the Enhanced Buffer
Master (EBM) mode of operation:
1. If using interrupts:
a) Clear the SPI1IF bit in the IFS0 register.
b) Set the SPI1IE bit in the IEC0 register.
c) Write the respective SPI1IPx bits in the
IPC2 register.
2. Write the desired settings to the SPI1CON1
and SPI1CON2 registers with the MSTEN bit
(SPI1CON1<5>) = 1.
3. Clear the SPIROV bit (SPI1STAT<6>).
4. Select Enhanced Buffer mode by setting the
SPIBEN bit (SPI1CON2<0>).
5. Enable SPI operation by setting the SPIEN bit
(SPI1STAT<15>).
6. Write the data to be transmitted to the SPI1BUF
register. Transmission (and reception) will start
as soon as data is written to the SPI1BUF
register.
To set up the SPI1 module for the Enhanced Buffer
Slave mode of operation:
1. Clear the SPI1BUF register.
2. If using interrupts:
a) Clear the SPI1IF bit in the IFS0 register.
b) Set the SPI1IE bit in the IEC0 register.
c) Write the respective SPI1IPx bits in the
IPC2 register to set the interrupt priority.
3. Write the desired settings to the SPI1CON1 and
SPI1CON2 registers with the MSTEN bit
(SPI1CON1<5>) = 0.
4. Clear the SMP bit.
5. If the CKE bit is set, then the SSEN bit must be
set, thus enabling the SS1
pin.
6. Clear the SPIROV bit (SPI1STAT<6>).
7. Select Enhanced Buffer mode by setting the
SPIBEN bit (SPI1CON2<0>).
8. Enable SPI operation by setting the SPIEN bit
(SPI1STAT<15>).
FIGURE 16-2: SPI1 MODULE BLOCK DIAGRAM (ENHANCED BUFFER MODE)
Internal Data Bus
SDI1
SDO1
SS1
/FSYNC1
SCK1
bit 0
Shift Control
Edge
Select
F
CY
Enable
SPI1BUF
Control
TransferTransfer
Write SPI1BUFRead SPI1BUF
16
SPI1CON1<1:0>
SPI1CON1<4:2>
Master Clock
Clock
Control
Primary
1:1/4/16/64
Prescaler
Secondary
Prescaler
1:1 to 1:8
Sync
SPI1SR
Transmit Buffer
8-Level FIFO
Receive Buffer
8-Level FIFO