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; }