This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

C5515 SPI interfacing EEPROM

Hi, I have a C5515 on a Spectrum Digital EVM5515 board. I want to communicate with the CAT25C265 EEPROM on this board. I have successfully configured the SPI in the loopback mode, however, I am not able to read the Status Register of the EEPROM using SPI (I always receive 0x0000). I followed the instructions in the datasheet (sprufo3). Here is my code: For now, I use breakpoints in the ISR to check the data register

#include "usbstk5515.h"

#define IER0 *(volatile unsigned*)0x0000
#define IER1 *(volatile unsigned*)0x0045
#define IFR0 *(volatile unsigned*)0x0001
#define IFR1 *(volatile unsigned*)0x0046

#define EBSR *(volatile ioport Uint16*)(0x1C00)
#define PRSCR *(volatile ioport Uint16*)(0x1C04)
#define PRCR *(volatile ioport Uint16*)(0x1C05)

#define SPI_CDR		*(volatile ioport Uint16*)(0x3000)
#define SPI_CCR		*(volatile ioport Uint16*)(0x3001)
#define SPI_CDR1	*(volatile ioport Uint16*)(0x3002)
#define SPI_CDR2	*(volatile ioport Uint16*)(0x3003)
#define SPI_CMD1	*(volatile ioport Uint16*)(0x3004)
#define SPI_CMD2	*(volatile ioport Uint16*)(0x3005)
#define SPI_STAT1	*(volatile ioport Uint16*)(0x3006)
#define SPI_STAT2	*(volatile ioport Uint16*)(0x3007)
#define SPI_DAT1	*(volatile ioport Uint16*)(0x3008)
#define SPI_DAT2	*(volatile ioport Uint16*)(0x3009)


void spi_isr()
{
	if (spistat & 0x0002) { // character complete
		SPI_DAT1 = SPI_DAT2 = 0;
		SPI_CMD2 = 0x0039; //8 bits/character, write mode, chip select 0
	}
}

void setup_ports()
{
	EBSR &= ~0x7000;
	EBSR |= 0x6000; // SPI output
	EBSR &= ~0x0008; // A18 Pin mode != GPIO
}

int main()
{
	setup_ports();

	IER1 |= 0x0008;

	SPI_CCR &= ~(0x8000);
	SPI_CDR = 0x2000;
	SPI_CCR |= 0x8000;

	SPI_CDR2 = 0x0000; 
	SPI_CMD1 = 0xC002; //2 char frame

	SPI_DAT1 = SPI_DAT2 = 0;
	SPI_DAT2 = 0x0005; //opcode for eeprom
	SPI_CMD2 = 0x003A; //8 bits/character, write mode, chip select 0
	IFR1 = 0;
}

  • Since you have the Spectrum Digital EVM, you should be able to run the SPI example in CSL, CSL_SPI_Example, which interface to the on-board CAT25C256 EEPROM. You can step through it.

    Hope this help.

  • Thanks for your reply. I downloaded the examples and imported the project into my workspace (it was an ccsv3 project). If I load the dsp with the binary and step through, it works. However, if I compile the same code, it does not (I only receive junk data). I also have to comment out the printf functions, because they cause the processor to hang. What could be the problem? I also tried using the gel file from spectrum digital with no success.
  • The latest version of CSL_3.04 is tested with CCS5. What version are you using? Suggest to install CSL in a new folder by following the installation guide.
    Regards.
  • EBSR looks incorrect - use PPMODE 3 or 5 to communicate with SPI EEPROM on this EVM:

    /* Enable SPICLK,RX,TX & CS0 */
    SYS_EXBUSSEL =(0x5<<12);

    Make sure clock gates are open to peripherals:
    /* Enable clocks to all peripherals */
    SYS_PCGCR1 = 0x0000;
    SYS_PCGCR2 = 0x0000;

    Reset the peripheral before use:
    /* Reset Counter value */
    SYS_PRCNTR = 0x04;

    /* Reset SPI Module */
    SYS_PRCNTRLR = 0x00ff;
    for(i=0;i<100;i++) {;}
    /* Enable SPICLK,RX,TX & CS0 */

    See Target Content on http://support.spectrumdigital.com/boards/evm5515/revb/
    (all these code excerpts taken from spirom test)

    Hope this helps,
    Mark