*****************************************************************************************

This ZIP File is associated with Rev 1 of the Application Note

    Connecting SHARC and Blackfin Processors over SPI (EE-340)
    
that can be found at http://www.analog.com/ee-notes.

Date Created:   July 8th, 2008

*****************************************************************************************


The archive provides 2 code examples:

Example 1 in directory ADSP-21369_SPI

Example 2 in directory ADSP-BF537_SPI


*****************************************************************************************

Example 1 in directory ADSP-21369_SPI

This code configures the primary SPI of the ADSP-21369 SHARC processor in master/slave mode. The SPI is configured as transmitter or receiver based on the
macro settings in SPI.h file. When configured as receiver after the DMA is completed the data received is compared with the known data.
In case of failure only one LED is toggled and for the passing case 3 LEDs on the ADSP-21369 EZ-KIT Lite board are toggled. 

The following are the files available in the project:

1. SPI.h file which has the macros for configuring the system and SPI.  
	a. The SET_CPHASE, SET_CLKPL and SET_CPHASE_CLKPL macros are used for selecting Clock Phase and Polarity for the SPI transfers. 
	b. Using the MS_TRANSMITTER/SL_TRANSMITTER macro the SPI can be configured as transmitter in DMA mode otherwise the SPI is used as receiver in DMA mode. 
	c.The core clock for the ADSP-21369 processor also can be defined using the PLL_XXX_MHZ macros. These macros allow the processor to run in the 
	configured core clock. The PMCTL register is configured as per the macro value selected.
	d. The SPI frequency can also be configured using the SPI_FREQ macro. Based on the value selected the SPIBAUD register value will be calculated and
	programmed by the application.(SPI Master) 
2.1 Configdai.asm which has the SRU routings for the SPI. The SPI signals are routed as follows (SPI Master):
	a. DPI 6 - SPI_CLK
	b. DPI 7 - SPI_MOSI		
	c. DPI 8 - SPI_FLG0
	d. DPI 13 - SPI_MISO
2.2 Configdai.asm which has the SRU routings for the SPI. The SPI signals are routed as follows (SPI Slave):
	a. DPI 6 - SPI_CLK
	b. DPI 7 - SPI_MOSI		
	c. DPI 14 - SPI_DS
	d. DPI 13 - SPI_MISO
	
3. InitPLL.asm - Configures the PLL as per the Core clock frequency selected.

4. SPI_Master_DMA.asm - Configures the SPI control registers for master mode DMA operation.The SPIBAUD rate is calculated automatically	based on the SPI_FREQ
   macro and core clock selected (SPI Master).

5. SPI_Slave_DMA.asm - Configures the SPI control registers for slave mode DMA operation(SPI Master). 



*****************************************************************************************

Example 2 in directory ADSP-BF537_SPI

There are two projects available, one for Blackfin SPI Master and one for Blackfin SPI Slave. In the Master/Slave subfolders, there is a specific main.asm file
and a specific configurations.h file, where all required settings are done and explained. The other files that can be found in the folder src are used in common
an Master/Slave relevant code is activated by preprocessor definitions. The SPI is configured as transmitter or receiver based on the macro settings in
configurations.h file. When configured as receiver after the DMA is completed the data received is compared with the known data.


BF537_SPI_[MASTER/SLAVE]
|
|-MASTER
| |
| |--_VDSP50_BF537_SPI_MASTER.dpj (Blackfin SPI Master project file)
| |--main.asm (Blackfin SPI Master project main source file)
| |--configurations.h (Blackfin SPI Master project configuration file)
|
|-SLAVE
| |
| |--_VDSP50_BF537_SPI_SLAVE.dpj (Blackfin SPI Slave project file)
| |--main.asm (Blackfin SPI Slave main source file)
| |--configurations.h (Blackfin SPI Slave project configuration file)
|
|-src
| |
| |--ADSP-BF53x_ASM.ldf
|
| |--bfstartup.asm (Blackfin Startup Code)
| |--data.asm (set up of tx_buf/rx_buf array containing data to be transmitted)
| |--ezkitBF537_led.asm (set up ADSP-BF537 EZ-KIT Lite LEDs)
| |--functions.asm (misc functions)
| |--INIT.asm (set up interrupts and gpio ports)
| |--IVGx_handler.asm (interrupt handler)
| |--libdsp.asm (include some blackfin library functions)
| |--SPI.asm (set up and run SPI transfer)
| |--system.asm (system functions)
|
| |--Blackfin_Memory_Map.h (memory map required in the linker description file)
| |--data.h
| |--ezkitBF537_initcode.h (required definitions for system initialization)
| |--ezkitBF537_led.h
| |--functions.h
| |--global.h
| |--INIT.h
| |--IVGx_handler.h
| |--libdsp.h
| |--macros.h (some macro definitions)
| |--nBlackfin.h (some additional definitions)
| |--SPI.h
| |--system.h


Open one of the project files in the MASTER / SLAVE folder.
Settings are done and described in 'configurations.h'.


Connecting ADSP-BF537 Blackfin Processor and ADSP-21369 Blackfin Processor:
Master SPI Blackfin Processor <---------->Slave SPI Sharc Processor
GND---------------------------------------GND
PF13/SPICLK------------------------------>DPI 6 - SPI_CLK
PF11/MOSI-------------------------------->DPI 7 - SPI_MOSI
PF12/MISO<--------------------------------DPI 13 - SPI_MISO
SSEL4/PF6-------------------------------->DPI 14 - SPI_DS

Slave SPI Blackfin Processor <---------->Master SPI Sharc Processor
GND---------------------------------------GND
PF13/SPICLK------------------------------>DPI 6 - SPI_CLK
PF11/MOSI-------------------------------->DPI 7 - SPI_MOSI
PF12/MISO<--------------------------------DPI 13 - SPI_MISO
/SPISS/PF14------------------------------>DPI 8 - SPI_FLG0


*****************************************************************************************

All code examples have been written and tested with

	VisualDSP++ 5.0 Update 3

	ADSP-21369 silicon revision 0.1

	ADSP-21369 EZ-KIT Lite revision 2.1

	ADSP-BF537 silicon revision 0.3

	ADSP-BF537 EZ-KIT Lite revision 2.1



*****************************************************************************************

    Connecting two ADSP-BF537 EZ-KIT Lite over SPI (not part of EE-340)

*****************************************************************************************

By default, PF4 is used for HOSTWAIT signalling on both sides.
Master PF4 -> input, Slave PF4 -> output.
Therefore SW5-3 on the ADSP-BF537 EZ-KIT Lite has to be OFF.


Connecting two ADSP-BF537 Blackfin Processors:
Master SPI Blackfin Processor <---------->Slave SPI Blackfin Processor
GND---------------------------------------GND
PF13/SPICLK------------------------------>SPICLKPF13/
PF11/MOSI-------------------------------->MOSI/PF12
PF12/MISO<--------------------------------MISO/PF11
SSEL4/PF6-------------------------------->/SPISS/PF14
HOSTWAIT/PF4<---------------------------->HOSTWAIT/PF4
