How to use USB RAM as ordinary RAM?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to use USB RAM as ordinary RAM?

1,658 Views
Garry_Hoberg
Contributor II

Hello everyone,

 

I'm using an LPC54628 with SDK 2.9 and trying to use the USB RAM (at addresses 0x40100000 to 0x40101fff) as additional ordinary RAM. So I do:

POWER_EnablePD(kPDRUNCFG_PD_RAM3);

In the Memory View after this instruction, instead of all ff all 00 is displayed. So power is actually on, it seems.

Then I do:

unsigned int *i = (unsigned int *)0x40101ffc;
*i = 0x12345678;

But that doesn't do anything. I then enabled USB0 clock, USB1 clock and USBPLL clock in the Clocks Tool, rebuilt and redebugged but no luck neither.

I also put .bss.* data via the managed linker script there (which was the idea, obviously) but the failed asserts tell that no values could be written there.

What am I missing? Do I have to set another register bit to make that area writable?

0 Kudos
Reply
5 Replies

1,426 Views
Kaisa
Contributor I

you have to enable the usb ram clock:

 

CLOCK_EnableClock(kCLOCK_UsbRam1);

0 Kudos
Reply

1,649 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello hoberg,

There is a demo steps you can refer to:

1) Create USB RAM space to save data:

Alice_Yang_0-1631770105284.jpeg

2) Initialize data to USB RAM:

#include "cr_section_macros.h"
__DATA(RAM5) uint32_t array[10];
 
3) You can check the address of “array”:

PRINTF("array address is %x\n",array);
 
4) Also can printf the data of address 0x40102000:
PRINTF("array is %x\n",*(uint32_t *)(0x40102000));

 

I attached the test project to you, you can have a look.

This project base on LPC55s69, the same method with LPC54628.

 

BR

Alice

0 Kudos
Reply

1,641 Views
Garry_Hoberg
Contributor II

Hi, Alice.

First off: Thank you for this quick reply. I opened this thread just before I finished work for the day and when I started today, your answer just sat there waiting for me. Perfect!

Then I unpacked the example and had a good look at it.

I tried your suggestions. I already had the USB_RAM section yesterday, labelled RAM3. So I did

 

#include "cr_section_macros.h"
__DATA(RAM3) uint32_t array[10];

 

in global scope. Later I did

 

POWER_EnablePD(kPDRUNCFG_PD_RAM3);
array[0] = 0x01234567;
array[9] = 0x89abcdef;

 

and then stepped through the code. The address of array is correct:

hoberg_2-1631781998414.png

But as you can see, all data is 0. In fact, all the USB_RAM is 0s. I tried omitting the POWER_EnablePD() line but then instead of 0s I get all 0xFFFFFEFFs (i.e.: 4294967039s).

Seems to me like for some reason the USB_RAM section is not writable. Odd.

Kind regards.

Garry

 

0 Kudos
Reply

1,633 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Garry,

Could you please share your project or a simple project that can reproduce your issue, I will check it on my side, thanks.

 

BR

Alice

0 Kudos
Reply

1,549 Views
Garry_Hoberg
Contributor II

I'm afraid the hardware design is going to change such that it includes an external RAM and I won't pursue this route any longer.

0 Kudos
Reply