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
  • 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.

Reply
  • 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.

Children
No data