This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Confusion over USB Fifo External Memory

I have a C8051F340. It has 4k of external ram, 256 bytes of ram and 1K of USB FIFO ram. I'm very confused on how to use the 1K of USB Ram as general purpose external ram with the Keil compiler.

The data sheet states that when the USBFAI bit in register EMI0CF is set to 1, the USB Fifo space is mapped into XRAM at address 0x400 to 0x7FF. It says the normal XRAM at the same address cannot be accessed at this point.

So I thought that I could set that bit and access the normal XRAM above 0x7FF (2k) and let it wrap around after 4k to get the first 2k. (5k gets mapped to 1k, etc). This didn't seem to work, however. Is this how its supposed to work?? How do I use the extra 1k? Is that 1k really not extra ram, but just the XRAM thats set aside for USB endpoints? Thank you!

Parents Reply Children
  • You said: It says the normal XRAM at the same address cannot be accessed at this point.

    That seems to be the answer to your own question. When you map in the 1kB FIFO RAM, you can't at the same time use all of the 4kB of external RAM.

    If you need the extra space, you will have to bank-switch, and preferably make sure that no interrupt routine makes use of any variables within the bank-switched range.

  • Thank you very much for the information. The guys at silicon labs insist that there is 5k of ram, but it appears thats not transparent with a C compiler.

  • "The guys at silicon labs insist that there is 5k of ram"

    They are correct: there is 5K of RAM.

    Nowhere do they claim that you can access all 5K simultaneously; in fact, your original post actually quoted the bit that says that you cannot access the 1K of FIFO and that 1K of XRAM simulatneously!

    "it appears thats not transparent with a C compiler"

    It has absolutely nothing to do with the 'C' compiler.
    You can switch that bit in 'C' and access the memory as described.

    You could even set up the banking support to do this "transparently" for you, if you wanted...

  • this is what I've done to test the memory:

    I've declared a variable
    static xdata uint8t_t test[1024] _at_0x400

    Now I write values to it and print them to the uart
    //EMI0CF |= 1<<6;

    for(i = 0; i < 1024; i++)
    { test[i] = i;
    } for(i =0; i < 1024; i++)
    { printf("%c ", test[i]);
    }

    This works fine.

    now if I do the same thing and select the alternate bank by setting the USBFAE bit in EMI0CF to 1, the memory is not written to at all.
    CLKSEL = 0x03;
    EMI0CF |= 1<<6;
    for(i = 0; i < 1024; i++)
    { test[i] = i;
    } for(i =0; i < 1024; i++)
    { printf("%c ", test[i]);
    }

    The USB clock should be enabled and we should now be pointing to the USB fifo data area, right??

    Thank you for you help.