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.

AM335x - displaying the contents of registers from a user application using READ_REGISTER_ULONG()

Hi

(using WEC7)

Is it possible to write a user app (C++ or C#) to see the contents of a peripheral register ie one of the AM335x SPI registers or the pad register?

I would like to do this so I can prove to myself that the driver has configured the peripheral register correctly

So far I've written an app that uses READ_REGISTER_ULONG() (in ceddk.dll) and by getting the virtual address from breaking into the SPI driver and using that as address I get the right answer from READ_REGISTER_ULONG() from a C# app.

What I would like to know is how can I get the register virtual address from the physical address? If I can get that then I can access the register. Everything I've tried to get the Virtual address has failed so far so any help would be appreciated.

Thanks

Terry

  • Additional to above -  the code I'm using in C#

        [DllImport("ceddk.dll", EntryPoint = "READ_REGISTER_ULONG")]           
        //ULONG READ_REGISTER_ULONG(__in volatile const ULONG * const  Register);
        public static extern uint read_reg_ulong(uint pRegister);

    ...


        //physical address = 0x48030000+0x12C = (MCSPI_CH0CONF McSPI channel 0 configuration register)
        //from the SPI driver the virtual address = 0x9003012C
        uint reg_addr = 0x9003012C;
        uint reg_contents = read_reg_ulong(reg_addr);

        //reg_contents now has correct data that was written to MCSPI_CH0CONF

  • Yes you can get the virtual address of any register. You will see this done in just about every driver's xxx_Init function. Usually takes the form of MmMapIoSpace(Physical_Address, sizeof(register).. or the like.

    You can also use the OAL function OALPAtoVA.

  • Hi David

    Thanks for the reply but I can't get MmMapIOSpace() to work. It keeps returning zero.

    Am I right in saying that if a register has already been mapped using this command that any further attempts to map to this area will cause a fail. If you want to get the Virtual Address you would have to unmap first using MmUnmapIoSpace()  (which I don't want to do) then map again?

    Regards

    Terry

  • MmapIoSpace should work as long as all the peripherals are mapped in your g_oalAddressTable.