Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
20 years ago

problems with flash and tri-state-bus

Hi everybody,

on a custom board, I use a tri-state-bus and cfi flash component to connect an amd compatible flash device with a 16 bit wide bus.

The entrypoint to my application is alt_main, no HAL drivers or interrupts are initialized. I am just using macros from io.h to access the flash.

# define AUTO_SELECT() {

(IOWR_16DIRECT((flash_base), 0xAAA, (ushort)0xAA));

(IOWR_16DIRECT((flash_base), 0x555, (ushort)0x55));

(IOWR_16DIRECT((flash_base), 0xAAA, (ushort)0x90)); }

# define CFI_QUERY() (IOWR_16DIRECT((flash_base), 0xAA, (ushort)0x98))

# define READ_RESET() (IOWR_16DIRECT((flash_base), 0xAAA, (ushort)0xF0))

# define READ_DIRECT(src, offset) (IORD_16DIRECT(src, (ushort)offset))

int main (void) __attribute__ ((weak, alias ("alt_main")));

int alt_main(void)

{

unsigned char *flash_base;

int val[10];

flash_base = (unsigned char *) EXT_FLASH_BASE;

while(1)

{

usleep(5000000);

CFI_QUERY();

val[0] = READ_DIRECT(flash_base, 0x20);

val[1] = READ_DIRECT(flash_base, 0x22);

val[2] = READ_DIRECT(flash_base, 0x24);

READ_RESET();

AUTO_SELECT();

val[3] = READ_DIRECT(flash_base, 0x00);

val[4] = READ_DIRECT(flash_base, 0x01);

READ_RESET();

}

}

The application just reads a few values from the CFI table and the manufacture and device ids.

I am using signal tap to monitor the adress, data, read, write and select pins.

Well, signal tap shows mor accesses to flash than the system should perform!

After CFI_QUERY() I can see 6 read cycles wehre only 3 should take place. The first to read cycles are doubled and and the last one reads from offset 0x26 (my last read incremented by 2).

In AUTO_SELECT() there is an additional write cycle to the address of my last cycle incremented by 2.

Does anybody know where the additional read and write cycles come from???

--wolfgang

1 Reply

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Ok, the problems seems to be related to the avalon bus.

    As I understand, the additional read cycles are related to the dynamic addressing

    and are ok, because the additional data is discarded by the bus.

    The additional write cycle indeed is a problem. As far as I could figure out, it occurs only writing to an odd address.

    I do not know if this is mentioned in any documentation, at least I could not find it. But it is known for sure, that I know after having a closer look to the HAL cfi flash driver and the development board schematics.

    Have fun,

    --Wolfgang