# Vault 7: Projects

This publication series is about specific projects related to the Vault 7 main publication.

### Protego

# PIC24FJ64GA004 -- Serial Peripheral Interface

- 1
- 2
…
- 33
- 34
- 35
- 36
- 37
…
- 41
- 42

 2014 Microchip Technology Inc. DS70005185A-page 35
Serial Peripheral Interface (SPI) Module
Example 5-1: SPI1 Transmission and Reception with DMA (Continued)
5.2 SPI and DMA with Null Data Write Mode
When the SPIx module is configured for Master mode, and only received data is of interest, some
data must be written to the SPIx transmit buffer in order to start the SPIx clock and receive the
external data. In this situation, use Null Data Write mode of the DMA. For more information on
DMA Null Data Write mode, refer to the DMA Family Reference Manual section specific to the
device.
SPI and DMA Interrupt Handlers:
void __attribute__((__interrupt__)) _SPI1Interrupt(void)
{
IFS0bits.SPI1IF = 0;
}
void __attribute__((__interrupt__)) _DMA0Interrupt(void)
{
static unsigned int BufferCount = 0; // Keep record of the buffer that
// contains TX data
if(BufferCount == 0)
{
TxData(BufferA); // Transmit SPI data in
// DMA RAM Primary buffer
}
else
{
TxData(BufferB); // Transmit SPI data in DMA RAM
// Secondary buffer
}
BufferCount ^= 1;
IFS0bits.DMA0IF = 0; // Clear the DMA0 Interrupt flag
}
void __attribute__((__interrupt__)) _DMA1Interrupt(void)
{
static unsigned int BufferCount = 0; // Keep record of the buffer
// that contains RX data
if(BufferCount == 0)
{
ProcessRxData(BufferA); // Process received SPI data in
// DMA RAM Primary buffer
}
else
{
ProcessRxData(BufferB); // Process received SPI data in
// DMA RAM Secondary buffer
}
BufferCount ^= 1;
IFS0bits.DMA1IF = 0; // Clear the DMA1 Interrupt flag
}

- 1
- 2
…
- 33
- 34
- 35
- 36
- 37
…
- 41
- 42