GPFI II interrupt CPU. reset global variable

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
MaMa_4034336
Level 3
Level 3

Hallo,

I'm working on a project on sending raw image data from an image sensor to the PC. It's quite similar to the UVC example, however it works with raw image data.

Since the image data have no information about new Frame and new Line, I'm putting these information in the firmware into the data with. Similar to the UVC header.

Everytime a new frame is coming, i have to reset my line counter (a global variable). I tried to do this with a interrupt from the GPIF II (intr_cpu). However, as far as i understande, the GPFI Callback doesn't see the global variable i defined and therefore can't manipulated my line counter.

Is there a possiblity to this and how.

Best regards,

Matthias

0 Likes
1 Solution

Hello Srinath,

I tried it and it looks like, the it run through the callback function befor it finished, sending the data. So the state machine still jump to the next state befor the Firmware is finish. However i rearrange my state, so that there are no two INTR_CPU in series.

Best regards,

Matthias

View solution in original post

0 Likes
9 Replies
SrinathS_16
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

Hello Matthias,

- The GPIF callback function can alter any global variable that has been defined in the firmware.

- You have mentioned that the information about the new frame/ new line is included as part of the image data. So, please let me know when the GPIF interrupt is invoked from the state machine.

Best regards,

Srinath S

0 Likes
lock attach
Attachments are accessible only for community members.

Hello Srinath,

the GPFI interrupt, which alterant the global variable are FRAME_END0 and FRAME_END1. In short the state machine works like: data are read in PUSH_DATA. If a line is finished, which is showen over the LV (Line-valid) input.In the state LINE_END0/1 the data is send to the CPU, where the header is inlcuded and then send to the PC and if the frame is finished, showen over the FV (frame-valid) input, the state machine goes to FRAME_END0/1, where the intr_cpu happen. I also included a DR_GPIO to see, if the state machine goes into the state FRAME_END0/1, what it does.

Picture of the state machine

pastedImage_0.png

this is my code in the Firmware. gloablheader is my global variable, which doesn't get altered.

void

CyFxGpifCB (

        uint8_t currentState            /* GPIF state which triggered the interrupt. */

        )

{

    /* The ongoing video frame has ended. If we have a partial buffer sitting on the socket, we need to forcibly

     * wrap it up. We also need to toggle the FW_TRG a couple of times to get the state machine ready for the

     * next frame.

     *

     * Note: DMA channel APIs cannot be used here as this is ISR context. We are making use of the raw socket

     * APIs.

     */

    switch (currentState)

    {

        case LINE_END0:

            CyU3PDmaSocketSetWrapUp (CY_U3P_PIB_SOCKET_0);

            break;

        case LINE_END1:

             CyU3PDmaSocketSetWrapUp (CY_U3P_PIB_SOCKET_1);

            break;

        case FRAME_END0:

            globalheader[2]=0;

            break;

        case FRAME_END1:

            globalheader[2]=0;

            break;

        default:

            /* This should not happen. Do nothing. */

            return;

    }

}

i also included my Project. The GPFI II Project is in de Project under "ImageProgrammGPIF.cydsn". the source code is in the file "bulkloop.c".

Best regards,

Matthias

0 Likes

Hello Matthias,

- I could perform a similar test setup as yours and do not find an issue. Please let me know if the state machine reaches the FRAME_END states through the GPIO status or by UART prints in the firmware GPIF callback.

- Also, one suggestion on the state machine:

--> Since the header is added only for every frame, instead of committing the data for every line, it can be modified to collect all the data in one complete frame and then commit the data.

Best regards,

Srinath S

0 Likes

Hello Srinath,

I can see, that the state is reach, with the GPIO toggle. The GPIO goes on the correct input Signal to high.

However i tried to send a UART print in any state and there is see no respones.

I set my callback function with the CyU3PGpifRegisterSMIntrCallback() function. In the FX3APIguide is :"Please note
that API calls that require a mutex get or equivalent cannot be directly called from this callback function.
". It sounds like i can change globale variable.

The header is always added at the end of a line to indicate a new line in Data, without the header i don't have any information when a line end and wenn a new start.

Best regards,

Matthias

0 Likes

Hello Matthias,

- Please check if the firmware reaches the GPIF II callback function by using the CyU3PDeviceReset(CyFalse) API and check if the device resets.

- Is there any other firmware code that alters the value of the global variable? If possible, share the firmware source.


Best regards,

Srinath S

0 Likes

Hello Srinath,

I checked the callback function with the CyU3PDeviceReset(CyFalse) and now I think i know what's happening.

The Callback function itself is called by a Intr_CPU. However in the FRAME_END0/1 the Intr_CPU is ignored. I think the it's because the Firmware itself is still in the Interrupt from the LINE_END0/1, when the Intr_CPU from the FRAME_END0/1 occur. When I delete the Intr_CPU from LINE_END0/1 the Intr_CPU from the FRAME_END0/1 occur normally and is not ignored.

Is it possible to wait in the state machine till the interrupt ended?.

Best regards,

Matthias

0 Likes

Hello Matthias,

- In the GPIF II state machine, modify the transition from the LINE_END0/1 state to FRAME_END0/1 state from !FV to !FV&FW_TRG. This will cause the state machine to wait for a trigger from the firmware after servicing the GPIF interrupt.

- In the firmware, at the end of the GPIF II callback function, use the CyU3PGpifControlSWInput (CyTrue); statement to invoke a firmware trigger.

A similar approach can be found in the AN75779 app note implementation.

Best regards,

Srinath S

0 Likes

Hello Srinath,

I tried it and it looks like, the it run through the callback function befor it finished, sending the data. So the state machine still jump to the next state befor the Firmware is finish. However i rearrange my state, so that there are no two INTR_CPU in series.

Best regards,

Matthias

0 Likes

Hello Matthias,

Please let me know if you are able to resolve the issue.

Best regards,

Srinath S

0 Likes