UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Explorer
Explorer
1,658 Views
Registered: ‎04-18-2017

Re: UIO Interrupt handling with petalinux

@deppenkaiser,

 

I am not sure that depends on the board but how you code and how you design your hardware and software....just wait until someone else replies, but I believe they will tell you the same. FYI, I am currently working with a pynq, zedboard and petalinux 2017.4.

0 Kudos
Contributor
Contributor
1,658 Views
Registered: ‎06-28-2016

Re: UIO Interrupt handling with petalinux

You may right, but now i have easter holiday i will test it later.

0 Kudos
Contributor
Contributor
1,652 Views
Registered: ‎06-28-2016

Re: UIO Interrupt handling with petalinux

You have a working Version me not. You are able to compare both i'am not.

 

You would help me so much if you will compare my complete Code that i was posted (only a few lines) with your working Code. juergen.kratochwill@grapho-metronic.com shows a difference, that i will test after the easter days next week; more differences are not visible.

 

0 Kudos
Contributor
Contributor
1,648 Views
Registered: ‎06-28-2016

Re: UIO Interrupt handling with petalinux

@aripod,

juergen.kratochwill@grapho-metronic.com,

@jrhtech

 

Are you using the petalinux default configuration for "zynq"

 

petalinux-create -template zynq -name myproject

 

or do you use the bsp from your board manufacturer?

 

0 Kudos
1,626 Views
Registered: ‎04-20-2017

Re: UIO Interrupt handling with petalinux

Zynqberry, zed board and trenz t04xx. I found zed board the easiest. Vivado design self built (no pre-made Bsp) petalinux-create like you wrote, import. Hdf file built project... Used uio with 2016.4,2017.1 now 2017.4.
Does not sound like a board related issue...
the code I pmd you is all you need and it proved to be working with several different uio devices and I told you some differences in your code that might be the source of the error. Good luck testing!
Explorer
Explorer
1,600 Views
Registered: ‎04-18-2017

Re: UIO Interrupt handling with petalinux

@deppenkaiser,

 

Check out this blog.

0 Kudos
Contributor
Contributor
1,562 Views
Registered: ‎06-28-2016

Re: UIO Interrupt handling with petalinux

juergen.kratochwill@grapho-metronic.com

 

i have solved my tcp/ip-select issue, so it's more clearly now.

 

Now i followed your guidance again and use the (void*) cast, it doesn't help. Now i have done everything that was told me and it is not working.

 

Here is the code:

 

bool UIOAccess_Initialize(SUIOAccessPtr pUIOAccess, index_t nDeviceNumber, index_t nMapNumber) 

{

    bool bRetVal = false;

    uiostr_t info = { 0 }; 

    FILE* hSize = NULL;

 

    sprintf(info, "/sys/class/uio/uio%d/maps/map%d/size", nDeviceNumber, nMapNumber);

    sprintf(pUIOAccess->file, "/dev/uio%d", nDeviceNumber);

    pUIOAccess->fd = INVALID_FD;

    pUIOAccess->page_size = sysconf(_SC_PAGESIZE);

 

    if ((hSize = fopen(info, "r")) != NULL)

    {

       rewind(hSize);

       fscanf(hSize, "%x", (uint32_t*) &(pUIOAccess->map_size));

 

       fclose(hSize);

 

       if ((pUIOAccess->fd = open(pUIOAccess->file, O_RDWR)) != INVALID_FD)

       {

          pUIOAccess->base_addr = (memadr32_t) mmap(NULL, pUIOAccess->map_size, PROT_READ | PROT_WRITE, MAP_SHARED,

             pUIOAccess->fd, pUIOAccess->page_size * nMapNumber);

          bRetVal = ((void*) pUIOAccess->base_addr) != MAP_FAILED;

       }

    }

 

    return bRetVal; 

}

 

bool UIOAccess_ActivateInterrupt(SUIOAccessPtr pUIOAccess) 

{

    bool bRetVal = false;

 

    if (pUIOAccess->fd != INVALID_FD)

    {

       int nValue = 1;

       bRetVal = write(pUIOAccess->fd, (void*) &nValue, sizeof(int)) != -1;

    }

 

    return bRetVal; 

}

 

bool UIOAccess_WaitForInterrupt(SUIOAccessPtr pUIOAccess) 

{

    bool bRetVal = false;

 

    if (pUIOAccess->fd != INVALID_FD)

    {

       int nValue = 0;

       bRetVal = read(pUIOAccess->fd, (void*) &nValue, sizeof(int)) != -1;

    }

 

    return bRetVal;

}

 

int ReadSwitches(SUIOAccessPtr pUIO) 

{

     MEMORY_ACCESS(pUIO->base_addr, GPIO_CHANNEL_1_DIRECTION) = 0xFFFFFFFF;

     MEMORY_ACCESS(pUIO->base_addr, GPIO_GLOBAL_IRQ_ENABLE) = 0x8000000;

     MEMORY_ACCESS(pUIO->base_addr, GPIO_IRQ_ENABLE) = 0x00000003;

     return MEMORY_ACCESS(pUIO->base_addr, GPIO_CHANNEL_1_DATA);

}

 

int main() 

{

    SUIOAccess uio_sw = { 0 }; 

   

    if (UIOAccess_Initialize(&uio_sw, 1, 0)) 

    {

        while(true) 

        {

            MEMORY_ACCESS(uio_sw.base_addr, GPIO_IRQ_STATUS) = 0x3; 

            printf("Switches: %d\n", ReadSwitches(&uio_sw));

 

            if (UIOAccess_ActivateInterrupt(&uio_sw)) 

            {

                UIOAccess_WaitForInterrupt(&uio_sw);

            }

        }

 

        UIOAccess_DeInitialize(&uio_sw);

    }

 

    return 0; 

}

 

The "ReadSwitches" function test the uio device and the propper Input configuration of the Interrupt source. Here the "/proc/Interrupts" file again:

 

Interrupts.JPG

 

What is wrong with my example?

 

0 Kudos
Contributor
Contributor
1,443 Views
Registered: ‎06-28-2016

Re: UIO Interrupt handling with petalinux

@aripod,

juergen.kratochwill@grapho-metronic.com,

@jrhtech,

 

now it works!

 

I had an error in my macro. I used the wrong pointer arithmetic (Offset calculation with wrong pointer type). But i'am still wondering why i could set the propper direction of the GPIO. Therefor i must set the values into the correct Register!?

 

But now i know that my macro was wrong.

 

0 Kudos
1,435 Views
Registered: ‎04-20-2017

Re: UIO Interrupt handling with petalinux

Glad you found it. I mentioned to you earlier that you should make sure that you are writing actually the register you think you do!
Well yes, but they also have a default setting from vivado. So in your case that most likely correlated then with the value you wanted to set...
0 Kudos
Contributor
Contributor
1,413 Views
Registered: ‎06-28-2016

Re: UIO Interrupt handling with petalinux

juergen.kratochwill@grapho-metronic.com,

 

yes, you told me that...

 

But i had to gpio's with both directions and both works. A Default can either be write ore read but not both.

 

I learned a lot because i had an issue, so it's ok :-)

0 Kudos