none
How to Test the GPIO Pins???? RRS feed

  • Question

  • Hello Sir

     

    Am working with the win ce6.0 and my responsiblity is to check with the gpio pins  and to test the pins whether the its high or low depending upon the value we set. and also i want to manually set the pin values in the coding and i want to note that particular pin value on the omapL138 board. Can any body tell how to check with default gpiotest.c.

     

    Vinoth.

     

    Tuesday, July 13, 2010 10:25 AM

All replies

  • This is something that is very platform specific. I know that my company provides a driver to access GPIOs and an example program. Does your OEM provide such a thing?

    If not, you can memory map the gpio registers in a driver and access them. Use the specification for your processor to see what bits need to be set/cleared and create a driver to control individual gpios. Then you can write a program to control the gpios through your driver.

    To see examples of using the GPIOs you can go through the Mainstone BSP or any other arm based BSP you have, it will 100% sure have code that handles GPIOs.

    Shai

    Tuesday, July 13, 2010 10:51 AM
  • Hello shai

     

     

     i dont know how to create the drivers and all i need to know how it will be test easily. because i ve a code came from the vendor . when i try to run that separately in a subproject or a new proj its showing lot of errors related to each and every line . i think the linking and  the include dir may the problem .thats another issue.i dnt know the solution to solve.

     

    1. Tell me a sample code that test a gpio read write and all the experience person only can able to teach the beginners. am the beginner.

     

    Vinoth.

    Wednesday, July 14, 2010 4:59 AM
  • To learn Windows CE from scratch you can take a training course/read through Bruce Eitman's blog / Read the news groups for specific questions that arise (you are not the first one learning this OS...).

    You have many blogs with code examples on the internet. Once you have a specific question you can post here. At least this is how I view the functionality of these groups...

    Regarding specific code for your own platform, you need to contact your platform provider for such a code. Every processor will require different code for gpio toggling.

    Shai

    Wednesday, July 14, 2010 6:05 AM
  • this is the code which is not working when i click that . exe in the remote display can u tell how to check this code when its run. where i want to test or check the gpio pins. pls tell the way  to solve my issue

     

     


    #include "main.h"
    #include "globals.h"
    #include "gpio.h"
    #include "kernelgpio.h"

    #define LOGTYPE_NONE     0
    #define LOGTYPE_ERROR    1
    #define LOGTYPE_INFO     2
    #define LOGTYPE_WARNING  3

    #define GPIO_TEST1           GPIO_0_00

    enum GPIO_TEST_MODE
    {
        GPIO_READ_ALL = 0,
        GPIO_READ_ONE,
        GPIO_READ_ALL_BUT_ONE,
        GPIO_WRITE_ALL,
        GPIO_WRITE_ONE,
        GPIO_WRITE_ALL_BUT_ONE,
        GPIO_VERIFY_ALL,
        GPIO_VERIFY_ONE,
        GPIO_VERIFY_ALL_BUT_ONE,

    } ;


    ///////////////////////////////////////////////////////
    // Global structure defining tests
    // also stores state information for later comparison
    ///////////////////////////////////////////////////////

    typedef struct
    {
        UINT32         Id;
        LPCTSTR        Name;
        BOOL           IsOutput;
        BOOL           CanChange;
        GPIO_DIRECTION Direction;
        GPIO_STATE     State;
    } GPIO_TEST_DATA;

    GPIO_TEST_DATA  g_GpioTestData[] = {
      { GPIO_0_00, TEXT("J30-Pin92"),          TRUE,  TRUE,  GPIO_DIRECTION_INPUT, GPIO_STATE_LOW  },
      { GPIO_0_07, TEXT("J30-Pin90"),          TRUE,  TRUE,  GPIO_DIRECTION_INPUT, GPIO_STATE_LOW  },
      { GPIO_2_15, TEXT("LCD-BLPwr"),          TRUE,  TRUE,  GPIO_DIRECTION_INPUT, GPIO_STATE_LOW  },
      { GPIO_4_00, TEXT("SD-INS"),             FALSE, TRUE,  GPIO_DIRECTION_INPUT, GPIO_STATE_LOW  },
      { GPIO_4_01, TEXT("SD-WP"),              FALSE, TRUE,  GPIO_DIRECTION_INPUT, GPIO_STATE_LOW  },
      { 0,       NULL,                         FALSE, FALSE, GPIO_DIRECTION_INPUT, GPIO_STATE_LOW  },
    };



    int TestKernelIoControl(int iTestNum, TCHAR *pIoControlCodeText,
                            DWORD IoControlCode, VOID *pInpBuffer, UINT32 inpSize,
                            VOID *pOutBuffer, UINT32 outSize, LPDWORD pOutSize,
                            BOOL bExpectedResult = TRUE, BOOL bExceptionExpected = FALSE );



    ////////////////////////////////////////////////////////////////////////////////
    // LogResult
    //   Abstracts logging to make calling and formatting easier
    //
    // Parameters:
    //   dwVerbosity    Kato logging verbosity.
    //   dwType         Defines text prefix to be added to log entry.
    //   wszFormat      PRINTF-type format string for log entry.
    //   ...            Optional paramaters used by PRINTF format string.
    //
    // Return value:
    //   None
    //  
    ////////////////////////////////////////////////////////////////////////////////
    void LogResult(DWORD dwVerbosity, DWORD dwType, LPCWSTR wszFormat, ...)
    {
        va_list pArgs;
        TCHAR msgFormat[300];
        TCHAR *prefix;

        switch(dwType)
        {
            case LOGTYPE_ERROR:
                prefix = TEXT("ERROR: ");
                break;

            case LOGTYPE_WARNING:
                prefix = TEXT("WARNING: ");
                break;

            case LOGTYPE_INFO:
                prefix = TEXT("INFO: ");
                break;

            case LOGTYPE_NONE:
            default:
                prefix = TEXT("");
                break;
        }
        wsprintf(msgFormat, TEXT("%s%s"), prefix, wszFormat);   

        va_start(pArgs, wszFormat);
        g_pKato->LogV(dwVerbosity, msgFormat, pArgs);
        va_end(pArgs);

        // Increment global error counter
        if (dwVerbosity == LOG_FAIL || dwType == LOGTYPE_ERROR)
        {
            g_dwNumTestErrors++;
        }
    }

     

    Wednesday, July 14, 2010 9:38 AM
  • Hi Vinoth,

     

    What ever you are asking is very elementry question. Just learn WinCE and then i am sure you would do it by yourself.

     

    With regard,

    Misbah

    Wednesday, July 14, 2010 10:14 AM
  • Hi Misbah

     

    I can know something about the wince stuff .,though am a beginner i want to learn lot many thing bec of the experience and learning the new things.could you tell how v can check the gpio pins on the EVM kit.

    this is the link to the omapL138.

    if its possible you can check the below link and u can come to know wat gpio pins i can easily find and test

     

    http://focus.ti.com/dsp/docs/litabsmultiplefilelist.tsp?sectionId=3&tabId=409&literatureNumber=sprab63b&docCategoryId=1&familyId=1621

    Wednesday, July 14, 2010 10:29 AM
  • Misbah:

    If this is so elementery, why didn't you provide an answer?  Now that would have been helpful

    Vinoth:

    The code that you provided doesn't actually do anything, it is a function prototype and a function for outputting a message.  You must have a main() and you must do something in your main().  The function prototype suggests to me that you probably need to call TestKernelIoControl() and pass it some parameters.  Without more information, I wouldn't begin to guess at what you need to pass in.


    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com
    Wednesday, July 14, 2010 12:33 PM
    Moderator
  • Hello Bruce

     

    Actually i cant able to post the full code though its keep loading i cant able to send the full file wat i compiled . pls tell the way that you people want to know wat the code does.? then i can proceed.

     

    Regards

    Vinoth.

    Wednesday, July 14, 2010 12:46 PM
  • Hi Bruce,

    I am sorry for my suggestion to vinoth .

     

    With regard,

    Misbah

    Wednesday, July 14, 2010 12:51 PM
  • Hello

    Actually i want to know how to write a value to the omapL138 from the c code and want to measure the value on the board.Pls tell how to configure to the omap i dont know wats the synatx for writing and reading the register.

     

    Vinoth,

    Thursday, July 15, 2010 5:34 AM
  • Hi Vinoth,

    The source code that you have shown is to perform a test for your WinCE device using CETK (Windows CE Test Kit).

    Refer http://msdn.microsoft.com/en-us/library/ms895503.aspx)  

    You need the following setup and requirements to perform the test implemented by your code.

    1. You need to have the device running with an image that has included CETK as a catalog item.

    2. You need to connect the device to a PC using Active Sync or any other valid connection listed in the reference mentioned above.

    3. You need to install the correct version of WinCE (Platform Builder) on your PC.

    4. Invoke the CETK application from PC.

    5. Download Ebook (available, I think probably from microsoft website) 'Windows Embedded CE 6.0 Fundamntals'  and follow the guidelines in chapter10.

    6. If you connect successfully to device using CETK, you may be able to see the GPIO_Test as an option in the list of tests/drivers.

    7. If you do not see your option, then probably more work may be required to implement the required test, that may require more expertise on WinCE development.

    Regards,

    Mansukh

    Thursday, July 15, 2010 10:19 AM
  • Hello

    Actually i want to know how to write a value to the omapL138 from the c code and want to measure the value on the board.Pls tell how to configure to the omap i dont know wats the synatx for writing and reading the register.

     Vinoth,


    The syntax is not difficult, but I don't know anything about your CPU so you need to get addresses from the documentation.

    You first need to map an virtual address to your register - see MmMapIoSpace() and similar functions for how to do that.  Then you will have a pointer to a register.

    To read:  value = *pMyRegister;

    from that you should be able to figure out how to write.

    You cannot do this from your application, it will need to be done in a driver or the kernel.


    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com
    Thursday, July 15, 2010 12:58 PM
    Moderator
  •  

    Hi bruce,

    Thnx for the reply

    I have a few questions. I have bought the omapl138 devkit from logic-PD to get accustomed to windows CE on omapl138. I want to use the header pins given to connect LCD panel as GPIO pins.

    1. Having gone through the documentation and pinmux utility I have found out that I would have to modify the values of the registers for pinmux to enable this change.I have also gone through the gpio test routine which can be run at the bootloader level .I want to modify the gpio test routine so that I can have a gpio test which will toggle the voltage at any pin on the header file. 
    2. My actual goal is to write a routine and build an app so that I can do the similar toggling thing from within the operating system (WIN CE).
    • As far as I have learned I feel one needs to write to a register address in the omapl138 to toggle a pin to high or low.Can you please let me know if there is any routine or documentation available which can help me get my task.
    • It would be great if you can guide me in modifying the existing file.

    THnx

    Vinoth

    Thursday, July 15, 2010 2:14 PM
  • Vinoth:

    Have you check with LogicPD to see if they already have a driver for doing this?  If they do not, Microsoft doesn't supply anything - so you will need to write a driver or modify your kernel to do it.

    The test that you are trying to run assumes that you the OEM have added support to the kernel for the test.  This is not a requirement for Windows CE.

    I cannot guide you to modify the file until you do some work to implement the backend support to the OS.  Again, check with your vendor to see if they have this already.


    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com
    Thursday, July 15, 2010 3:13 PM
    Moderator
  • this is the one i got it from the spi,c

        pDevice->pSPIRegs = (PSPIREGS)MmMapIoSpace(pa, sizeof(OMAPL13X_SPI_REGS), FALSE);

     

    From this i tried to work with my own code

     

    printf("Value of register %d = %d\n", 2,INREG32(PUPPRegs) MmMapIoSpace(pa, (20), FALSE));but its not compiling .

    Can you tell me how i want to declare. give an eg for this to execute.

     

    Vinoth.

    Friday, July 16, 2010 1:22 PM
  • Vinoth:

    I don't understand - you are showing us an example.

    It would help if you told us what the error is and what in the heck that line of code is supposed to do.  It certainly doesn't make sense to allocate a resource and then throw it away like that.

    You should take the time to read the documentation for MmMapIoSpace() which that code tells me that you did not do.  You should take the time to read the documentation for your processor.

    Finally, did you ask your vendor if they have a solution yet?


    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com
    Friday, July 16, 2010 1:51 PM
    Moderator
  • Bruce,

     

    ya am reading the documentation and i bought the ms win ce books and am learning that y am asking the doubts to you people have some exp in that field am akng the doubt . though am a beginner i want to learn a lot. so with you people guidence i can go fwd..

     

    Regards

    Vinoth

    Monday, July 19, 2010 12:28 PM
  • Vinoth:

    To my amazement, the documentation for MmMapIoSpace() fails to mention that the mapping should be unmapped using MmUnmapIoSpace().

    That knowledge is important for understanding why you shouldn't have a line of code like your printf.

    I cannot tell you why it isn't compiling becuase you haven't told us what the error is.


    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com
    Monday, July 19, 2010 2:56 PM
    Moderator
  • Bruce,

    Thank you very much for you help and guidance. We were able to get the compilation to work. We were able to find few examples in the design kit and followed it for our example. We had some linking issues too, but once we pointed to the right library, link also went through. It looks like we have to use the HalTranslateBusAddress command in conjunction with the MmMapIoSpace command as per the MSDN guidelines. We saw an example and tried the following:


        HalTranslateBusAddress(Internal,0, PortAddress,&inIoSpace,&PortAddress);
        m_pUPPRegs = (OMAPL13X_UPP_REGS*)MmMapIoSpace(PortAddress, sizeof(OMAPL13X_UPP_REGS), FALSE);
        printf("value of virtual address base in hexal = 0x%X\n", m_pUPPRegs);
        printf("value of register in hexal = 0x%X\n", *(m_pUPPRegs));

    We have defined PortAddress as the base address for the UPP register section in the Omap L138 which is 0x01E16000. This register is read only and has the value 0x44231100. So we thought it would be a good exercise to just map this physical address to a virtual address and then read the value of the virtual address and check that we can get this 0x44231100. When we run the program, we get the virtual address as 0. Secondly, when we try to access the content of m_pUPPRegs, the execution crashes with the following coming on the display:

      48838 PID:6ce000a TID:6cf000a value of virtual address base in hexal = 0x0
      48838 PID:6ce000a TID:6cf000a Exception 'Data Abort' (4): Thread-Id=06cf000a(pth=8277c000), Proc-Id=06ce000a(pprc=82774d88) 'UPPTest.exe', VM-active=06ce000a(pprc=82774d88) 'UPPTest.exe'
      48839 PID:6ce000a TID:6cf000a PC=000119a8(UPPTest.exe+0x000019a8) RA=0001199c(UPPTest.exe+0x0000199c) SP=0002fd60, BVA=00000000

    We are not sure what exactly is the mistake here in the code since virtual address comes out as 0 and then when we try to pull out the content of the virtual address which should be equivalently the content of the UPP base address of 0x01E16000, the failure occurs.

    Can you please look into the code above and give your thoughts?

     

    Thanks again for all your help

    Vinoth

    Tuesday, July 20, 2010 1:03 PM
  • MmMapIoSpace returns NULL on an error so it is not liking something about what is being called.

    A few notes on your code, does HalTranslateBusAddress return success or failure?  If it returns failure I would call GetLastError to see if you can get more information on it.  If it fails, there is no point to call MmMapIoSpace.

    In your code I don't see any issues with your call to MmMapIoSpace so I would assume that PortAddress is likely not valid.  This would likely be the case if HalTranslateBusAddress failed.  You can also call GetLastError here to try to get more information on why it is failing.

    NULL or 0 is not a valid virtual address.

    EDIT: I forgot to mention, you don't need to call into HalTranslateBusAddress if you are using a Memory Address.  I believe that the OMAP register would be and if that is the case you can simply stuff the Physical Address in PortAddress and omit the call into HalTranslateBusAddress.

    That said, I don't know of anything anything wrong with calling HalTranslateBusAddress before calling MmMapIoSpace but you should probably check inIoSpace to make sure it is 0 before calling MmMapIoSpace.

    Good Luck.

    Tuesday, July 20, 2010 3:31 PM
  • I don't see anymore wrong with your code than Bradley pointed out.

    What i suspect is the problem is that you can't do that from an application in Windows CE 6.0, so you need to either write your code in a driver or the kernel.

    And again I will ask you, did you check with your vendor to see if they already have a solution?


    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com
    Thursday, July 22, 2010 12:37 PM
    Moderator
  • Bruce

    My vendor doesn't having   the solution. and am getting the result as 0. could you correct thecode if there any errors exists means. Bec i tried my level best. this is the time for the experience person like you to give a solution for this.And i studied in the forum, also that i cant use that MmMapIoSpace in the user mode Isit So ?

    They are mentioning that i can able to access the register  only through the kenel mode. can you tell me how to use the kenel mode i dnt ve an idea . tell me the clear way for my problem.

    this helps me to solve my whole issue .

    Thanks for the people who are helping me.

     

     

    Regards

    Vinoth.

    Thursday, July 22, 2010 12:49 PM
  • Write the code in a kernel mode driver or in the kernel itself.

    http://geekswithblogs.net/BruceEitman/archive/2008/08/13/windows-ce-device-driver-summary.aspx


    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com
    Thursday, July 22, 2010 2:53 PM
    Moderator
  • Bruce

    I saw your blogs. one thing i want to  create a dll i can c your sample code and create and i want to create a kernel that can access the memory map i dont find any sample code that describe how you mapped or how to do. Will u explain or explain wit a sample c code.

     

     

    Regards

    Vinoth.

    Friday, July 23, 2010 12:36 PM
  • You already know how to map the register in the driver - put your code into the driver.

    I suspect that if you look at your kernel, you will find that it already maps the register (or full set of CPU register) in OEMAddressTable.  You may even find code there that already accesses the GPIO registers.


    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com
    Friday, July 23, 2010 1:20 PM
    Moderator
  • Vinoth:

    Are you making progress?


    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com
    Thursday, July 29, 2010 12:38 PM
    Moderator
  • Bruce

     

    I tried with the virtual alloc and virtual copy but i can see vitual alloc is working but the  virtual copy is not working its return the null as the output. i want to know whether i want to make any changes or to enable something that allows me to get result of virtual copy.  these are the steps which am following in the code.

    this is the code 
    static MEMORY_REGISTER_ENTRY _pRegEntries[] = {
        { 0x01E16000,          0x400,      NULL},
       };

    typedef struct {
        DWORD       dwStart;
        DWORD       dwSize;
        void       *pv;
    } MEMORY_REGISTER_ENTRY;

    if (pRegEntry->pv == NULL)
                        {
                        // reserve virtual memory and map it to a physical address
                       
                            printf("Stage 6 \n");
                        pRegEntry->pv = VirtualAlloc(
                                            0, pRegEntry->dwSize, MEM_RESERVE,
                                            PAGE_NOACCESS
                                            );
                      //  pRegEntry->pv = 0x10000;
                        if (pRegEntry->pv == NULL)
                            {printf("Stage 7 \n");
                            DEBUGMSG(TRUE, (
                                L"ERROR: MmMapIoSpace failed reserve registers memory\r\n"
                                ));
                            goto cleanUp;
                            }
                        SetKMode(TRUE);
                       
                        rc = VirtualCopy(
                                pRegEntry->pv,(PVOID )(pRegEntry->dwStart >> 8),
                                pRegEntry->dwSize,
                                PAGE_PHYSICAL|PAGE_READWRITE|(cacheEnable ? 0 : PAGE_NOCACHE)
                                );
                       
                            printf("Stage 8, rc = %d \n", rc);
                        }
                    printf("Get Last Error after VirtualCopy = %08X\n",GetLastError());


    Am getting RC=0 as the result. can you tell me what went wrong in the above code.,

     

    Thanks for your help that makes me to progress .

     

    Vinoth.

    Friday, July 30, 2010 10:49 AM
  • Vinoth:

    As I have pointed out before, the code needs to be in a kernel mode driver or in the kernel - so where are you putting this code?  The fact that you are using printf suggests that it is in an application, where of course it will fail.


    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com
    Friday, July 30, 2010 11:49 AM
    Moderator
  • Bruce

     

    Am using the code in the driver directory where the BSP drivers are located.i added into that and i created a new project and the code which i sent you is the lib file . and am calling that lib file in another file that is executable and am running the exe through the remote display. can you tell me what went wrong in the above code.??? why the virtual copy not working.pls tell i ll correct it i dnt knw hw to enable the kernel mode. Would you explain.

     

    Vinoth.

    Friday, July 30, 2010 12:40 PM
  • Huh?  From that description, you are doing it from your app.

    You may have built code in a Drivers folder, but that doesn't make it a driver.  What makes it a kernel mode driver is that the driver is loaded by the kernel device manager.  To do that, it would need to actually be a driver.

    What you are describing is a statically linked library which you are linking to your application - so it is your application.

    Over the weekend I will try to post a generic solution on my blog.


    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com
    Friday, July 30, 2010 12:52 PM
    Moderator
  • Vinoth:

    I posted three articles today to discuss how to:

    1. Write a driver to access GPIO registers - see http://geekswithblogs.net/BruceEitman/archive/2010/08/01/windows-ce-using-a-driver-to-readwrite-hardware-registers.aspx
    2. Write wrapper functions to access the driver - see http://geekswithblogs.net/BruceEitman/archive/2010/08/01/windows-ce-developing-an-api-to-access-a-driver.aspx
    3. Write an application to read and write GPIO pins - see http://geekswithblogs.net/BruceEitman/archive/2010/08/01/windows-ce-writing-an-application-to-test-gpio-pins.aspx

    I include all of the source code, sources files, makefiles, bib files and reg files.  Everything you need, except that you will need to port the driver to your CPU/GPIO registers.


    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com
    • Proposed as answer by Prabu[MCTS] Monday, August 2, 2010 2:19 AM
    Monday, August 2, 2010 12:54 AM
    Moderator
  • Bruce

     

    Thanks for your help i really thankful for the thing which you did. You helped me when am struggled now i can able to read the address of the physical address with your code.

     i did the following and the issue is

     

    1.I changed the pinmux bsp_cfg.h file to make the bank 7 as the gpio because in the omapL138 there is no GPIO out so i changed .

    2.And even i read the value of the particular pin which i changed from the c code which i set.

    But i cant able to set the particular pin to high or low whether to check the gpio is toggling.

     

    Thanks again

    Vinoth.

    Enginner

    IQC Advanced Inspection Solution

    www.iqcgroup.com

    Tuesday, August 3, 2010 12:41 PM
  • Vinoth:

    I cannot express enough that we do not know anything about your hardware or your BSP.  So when you say that you "changed the pinmux bsp_cfg.h", which is not a file that I provided, we have no idea what you are telling us about.  Even if we did, it is highly unlikely that we would know what you changed since you don't even begin to tell us about your change.

    Certainly you will need to modify the code that I provided on my blog.  You will need to modify the GPIO_REGISTERS structure to match your hardware and you will most likely need to modify the IOCTL handling of both IOCTL_SET_GPIO_PIN and IOCTL_CLEAR_GPIO_PIN to match your hardware.  For that matter, you may need to change the entire IOCTL handling to match your hardware.  And of course you will need to modify the physical address.


    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com
    Tuesday, August 3, 2010 1:20 PM
    Moderator
  • Bruce :

    I have had a few problems when i modify the GPIO_REGISTERS that fits our device GPIO registers configuration.

    Whenever I try to write to read from any of these registers( post mapping), I am only able to gain access to the first register of the mapped memory.

     

    Where as when I change the base address (increment it, and the change the structure  )in such a way that my SETREG is the first register in the mapped memory, I am able to write and read out of it.

    I am pasting the new structure I have defined and also the Physcial memory mapping of the GPIO registers of our device.The Omap L138(TI's).

    typedef struct _GPIO_REGISTERS_
    {
        volatile DWORD DirectionReg;
        volatile DWORD Reserved1;
        volatile DWORD Reserved2;
        volatile DWORD Reserved3;
        volatile DWORD outputReg;
        volatile DWORD Reserved4;
        volatile DWORD Reserved5;
        volatile DWORD Reserved6;
        volatile DWORD SetReg;
        volatile DWORD Reserved7;
        volatile DWORD Reserved8;
        volatile DWORD Reserved9;
        volatile DWORD ClearReg;
        volatile DWORD Reserved10;
        volatile DWORD Reserved11;
        volatile DWORD Reserved12;
        volatile DWORD ReadReg;
    } GPIO_REGISTERS;

     

    Please find the GPIO register config for mour device in the page  of the PDF found in the following link.

    http://focus.ti.com/lit/ug/sprufl8b/sprufl8b.pdf

     

    Thanks and Regards

    Vinoth.p

     

     

     

    Friday, August 6, 2010 9:55 AM
  • Hi,

    It looks the register mapping of your device and structure declaration doesn't match.

    typedef struct _GPIO_REGISTERS_
    {
        volatile DWORD DirectionReg;
        volatile DWORD outputReg;
        volatile DWORD SetReg;
        volatile DWORD ClearReg;
        volatile DWORD ReadReg;
    } GPIO_REGISTERS;

    I guess reason for able to read only one register might be while mapping you might have specified only one register, instead of specifying entire structure size. May be code snippet will be helpful for members to look where exactly the issue is.

    Thank You & Regards,

    GSR

    Friday, August 6, 2010 10:31 AM
  • Hi GSR,

    • If you look at the gpio register sequence in the link specified .You would notice that the address offset between the DirectionReg, OutputReg and SetReg, is not 1 address value but 4. ie
    • 88h---->DirectionReg, *Ch--->OutputReg,90h----->SetReg  and so on, in page no 25 of the PDF >>>  http://focus.ti.com/lit/ug/sprufl8b/sprufl8b.pdf.
    • What I thought was since there is a one to one mapping between the virtual space and the phsycial address space.The offset needs to be preserved,Hence I  introduced some dummy registers in between to ensure the exact mapping.
    • If I am not right please let me know what shoudl be done
        
    Friday, August 6, 2010 11:04 AM
  • Hi,

    • Each GPIO register is 4-Bytes (32-Bit), so you don't need a reserved field in between them.
    • from windef.h if I see size of DWORD it is typedefed as unsigned long.

    Thank You & Regards,

    GSR

    Friday, August 6, 2010 11:26 AM
  • hi,

    But the physical register size inside the device is also 32-bit wide.

    • Doesn't it mean that the  address points to a 32-bit wide register.
    • Isn't every address(at least th ones mentioned) in the Physical Memory mapped to a 32-bit register.
    • My intention in having a dummy register is to have the offset in address but not to make use of the dummies because physically the dummies(physical 32-bit registers at addresses between 88h and 8Ch might not exist).
    • The OS doesn't know whether there is physically an address available at the addresses between 88h and 8Ch right.
    vinoth.p
    Friday, August 6, 2010 11:35 AM
  • Hi,

    If I understood correctly what you are saying is the addresses such as 0x89, 0x8A, 0x8B are reserved right ?

    The memory layout will be as given below inside processor.

    Reg-0 @ 0x80000000 [31:24] [23:16] [15:8] [7:0]
      0x80000003 0x80000002 0x80000001 0x80000000
    Reg-1 @ 0x80000004 [31:24] [23:16] [15:8] [7:0]
      0x80000007 0x80000006 0x80000005 0x80000004

    From above example assume I have two GPIO registers in my processor one is at 0x8000 0000 and the other one is at 0x8000 0004.

    In that case the bits [31:24], [23:16], [15:8] and [7:0] will be at the following addresses inside the processor 0x8000 0003, 0x8000 0002, 0x8000 0001 and 0x8000 0000 respectively.

    The next GPIO register which is at offset 0x8000 0004 layout can also be seen in the above table.

    I hope this clarifies your question. Whether the registers access supports 8-Bit and 16-Bit you have to refer respective Techinical Reference Manual. For example if you want to know whether OMAP-L1 GPIO registers can be accessed BYTE wise are not you have to refer the GPIO TRM. (Its nothing but the URL which you already have.)

    Thank You & Regards,

    GSR

    Friday, August 6, 2010 11:56 AM
  • Vinoth:

    I think that you are off in your understanding of addressing.  I have not looked at the datasheet, but from your description you have a register at offset 88, followed by one at 8C and one at 90.   These are each 32 bits from each other.

    Since you didn't beleive GSR, why don't you take a few minutes to prove or disprove it.  Output the address of each of your structure members and the value, including the reserved members.   You will see that the addresses of the reserved members line up with your physical registers and are 4 off from each other.  4 turns out to be sizeof(DWORD), or 32 bits.

    And if that isn't enough, look at my article again and notice the addresses of my registers and review the structure.  You will see that I have 2 - 32 bit registers between each of my registers, where i think that you have 0 - 32 bit registers between your registers.


    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com
    Friday, August 6, 2010 12:01 PM
    Moderator
  • hey Bruce and GSR,

    I would try it our with your suggestions.Since this is the first time I was dealing with the processor,I was thinking there was an offset intentionally in place.

     

    Thnx

    vinoth.

    Friday, August 6, 2010 12:07 PM
  • GSR:

    Very nice description.


    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com
    Friday, August 6, 2010 1:11 PM
    Moderator
  • Bruce & GSR

     

    thanks for helping me .if there  is any issue  let you know.

     

    Regards

    Vinoth.

    Monday, August 9, 2010 7:34 AM