Hi,
I've been using the SPI interface to load a design into an Altera Cyclone IV E fpga. I've converted a .sof file into a compressed .rbf file. Then using a hex editor I've converted this .rbf file into an array of bytes which lookes like this :
const unsigned char configData[728076] =
{
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0x6A, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF3, 0xFB, 0xF3, 0xF9, 0xFB, 0xF1, 0xF1, 0xF9, 0xF9,
...
...
Previously I've been using a simpler design which only had 514231 bytes. I've tested it and it worked fine. Byt now after replacing the design with the new one (728076 bytes long) something went wrong. Everything still works also fine when I load the design into the fpgawith a usb blaster then and I'm able to read the correct values from fpga's registers. Only when I load the new design over SPI is when it fails and I read gibberish. The thing is that the configuration seems to be working (CONF_DONE goes high). Here's the code that I'm using to load the design into the fpga:
void fpgaConfig(void)
{
int i;
const int length = 728076;
uint16_t temp;
spiDAT1_t dataConfig;
gioSetBit(spiPORT1, SPI_PIN_SOMI, 0); // nConfig low
delay(0xffff); // wait
gioSetBit(spiPORT1, SPI_PIN_SOMI, 1); // nConfig high
while(gioGetBit(spiPORT1, SPI_PIN_ENA) == 0); // wait until nStatus is high
spiSetFunctional(spiREG1, spiREG1->PC0 | (1U << SPI_PIN_SOMI)); // set nCONFIG as SPI pin
dataConfig.CSNR = 0;
dataConfig.CS_HOLD = 0;
dataConfig.DFSEL = SPI_FMT_0;
dataConfig.WDEL = 0;
//length = sizeof(configData);
for(i = 0; i < length; i++)
{
temp = configData[i];
spiTransmitData(spiREG1, &dataConfig, 1, &temp);
}
while(gioGetBit(spiPORT2, SPI_PIN_CLK) == 0); // wait until CONF_DONE is high
while(gioGetBit(gioPORTB, 7) == 0); // wait until INIT_DONE is high
}
Any ideas why could this be happening?