This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Accessing memory mapped registers



Hi,

I want to know if it is possible to access memory mapped registers of a device in CCS development environment (say a device-id register of DM6446). If it is possible, then how to access it??

Regarding this I searched through the CCS help documentations, this forum and google. But I couldn't find any useful information.

Thanks in advance.

Regards,

Karthick

 

 

 

  • There are a couple of ways of viewing memory mapped registers within CCS, on most devices the majority of the registers will be available under the view -> registers menu of CCS, though this mechanism is often missing registers for some devices. If the register you want to view is not there than you can view the register manually using a view -> memory window, with the view memory window you just have to put in the address of the register in question and you can both view and modify the register's value.

  • Thanks for your reply. I can see memory mapped registers in "view -> memory" window.

    Actually I was looking out for a way to access these registers in my C code, while running the code thru CCS(Apologies for not mentioning this clearly in my original post). The actual problem is that, the device datasheet mentions the physical address of the memory mapped registers, but the CPU can access it only through its virtual address. So the problem actually boils down to finding virtual address from a given physical address. Is it possible to do it in CCS environment?

    Karthick

  • I am curious which processor on the DM6446 you are working with (ARM/DSP)?

    If you are working with CCS I would guess you are working with the DSP in which case there is no virtual addressing, the DSP accesses the memory map directly as it has no MMU, so to access a register with the DSP you would be able to do so with a pointer with some code like:

    int * myreg;     //declare register pointer
    myreg = (int *) 0x80000000;     //address of register
    *myreg = 5;     //set this value to the register

    If you mean from the ARM side than the answer would depend on the OS you intend to run, and is largely independent of CCS, in the case of Linux you would have to make accesses to registers at the driver level, in which case I would generally start with an existing driver that is similar to what you are trying to implement and modify it to suit your needs.

  • As Bernie mentioned, virtual addresses pertain to ARM CPU.  Another point to be made is that Linux (uses virtual addresses at the user level) and CCS do not co-exist very well together.  Therefore, you should not be using CCS on ARM if you are running Linux (or other OSes).

  • Thanks to Bernie and Juan's replies.

    I am using ARM side of DM6446. From your replies I can understand that I cannot access a memory mapped register(on ARM side) unless I run a OS.

    Say if am using Linux, then I will have to make a call to a OS function(defined in Linux kernel) to get virtual address of a particular physical address. Since CCS doesn't understand that OS function the code will not get linked. Is my understanding correct?? In case of linux one can switch to gcc compilers to get it linked and run the code directly without using CCS.

    Actually, we are planning to use Nucleus RTOS. It supports CCS as CDE. So we are supposed to use compilers that come with CCS for generating ARM side libraries. So if my code makes a call to the Nucleus RTOS function, how will CCS behave in this scenario? Is there any way to compile and run a code in CCS, that calls a OS function.

    Karthick

     

  • Karthick said:
    I am using ARM side of DM6446. From your replies I can understand that I cannot access a memory mapped register(on ARM side) unless I run a OS.

    I am not sure that is 100% the case, we only really work with the ARM running a high level OS, namely Linux (which is effectively not debuggable with CCS), so at least my experience using CCS to debug the ARM is limited. I can say that because the ARM has a MMU there may be additional initialization procedures that need to happen for you to access physical memory directly from the ARM, handling the MMU is one of the big parts of what a high level OS does for you. It looks like setting up the MMU could be a significant effort, you may have to do some more digging around to see what really needs to be done, but there are some thoughts in a ARM forums thread here that may help. You may also want to work with your RTOS vendor to see what sort of ARM MMU support they have built in, if their OS is built to run on the ARM than they probably handle the MMU for you already.

    Karthick said:
    So if my code makes a call to the Nucleus RTOS function, how will CCS behave in this scenario? Is there any way to compile and run a code in CCS, that calls a OS function.

    OS functions are just more code to CCS, it makes no delineation, as long as it is linked into the binary you load to the target board it should be executable. I would guess that the RTOS would come as libraries you link in, so they should run properly but if you do not include the source in the project you will not be able to step through for debugging.

  • Karthick,

    You should be able to access ARM-sdie memory mapped registers thru CCS so long as Linux (or other high level OS that enables MMU) is not running.

  • Thanks for your valuable suggestions.

  • Y dont you write a low level linux driver that will help you to return the value of the register you are looking for?

    This will be also more helpful whilst debugging and be very handy :)

    Thanx!

    Sundar

  • Hello,


    I have the same problem and I was not going to make a new topic:

    I have DM3730 on bealgelboard-xm, I use xds560r and ccs 4.12.

    I can compile my C codes both on ARM and DSP side from CCS and use the above
    mentioned solution to access all register:
    
    
    
    
    int * myreg;     //declare register pointer
    myreg = (int *) 0x80000000;     //address of register
    *myreg = 5;     //set this value to the register
    
    
    
    
    My problem/guestion is that is there a way to access singel bit-in register without writing
    over the whole register content. It is pretty annoying if  i use the same register several times
    and forget what value i gave the register previously and then overwrite some configuration bits.
    Or is there already some predefined header files for DM3730 registers.
    
    
    
    
    Thanks