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.

c6678 NDK and CPU interrupt

Other Parts Discussed in Thread: SYSBIOS

hello:

I am using NDK, I have 4 interrupt include network interrupt ,and I find that code in the .cfg:

Ecm.eventGroupHwiNum[0] = 7;

Ecm.eventGroupHwiNum[1] = 8;

Ecm.eventGroupHwiNum[2] = 9;

Ecm.eventGroupHwiNum[3] = 10;

This mean the  event  4~31 wil be mapped to CPU interrupt 7,and event 31~62 mapped to CPU interrupt 8, and so on.

if my project have 4 event between 4~31, and  It may happen that the 4 event come together, only one event can be serverd by the ISR,because 4 event use one ISR.

So other event may not be severed by  the ISR,witch leads to event loss.

1.Now I don't want to use event Group, 4 event mapped to 4 ISRs!  I remove the 4 lines  event Group code, and the run my project, the net is not OK and interrupt does not work! Why??

2. if I want to achieve my idea, what need I do?

 

ThankS!

 

 

  • the nimu_eth.c ,function Setup_Rx(), have some codes:

       /* Register interrupts for the system event corresponding to the      * accumulator channel we are using.      */     /* System event n - Accumulator Channel 0 */    

     eventId      =   PLATFORM_ETH_EVENTID;

        /* Pick a interrupt vector id to use */    

     vectId          =   PLATFORM_ETH_INTERRUPT;

        platform_write ("Ethernet eventId : %d and vectId (Interrupt) : %d \n", eventId, vectId);

        /* Register our ISR handle for this event */   

      EventCombiner_dispatchPlug (eventId, (EventCombiner_FuncPtr)EmacRxPktISR, (UArg)ptr_net_device, TRUE);     EventCombiner_enableEvent(eventId);

        /* Map the event id to hardware interrupt 7. */    

      Hwi_eventMap(vectId, eventId >> 5);

        /* Enable interrupt */   

      Hwi_enableInterrupt(vectId);

    I think the evet group below has nothing to do with the NDK RX,But when I remove the event group, the helloworld demo does't wok! Why ?

    Ecm.eventGroupHwiNum[0] = 7;

    Ecm.eventGroupHwiNum[1] = 8;

    Ecm.eventGroupHwiNum[2] = 9;

    Ecm.eventGroupHwiNum[3] = 10;

     

  • Hello,

    I'm looking into this now and will let you know what I find.

    Sincerely,

    John Demery

  • After reviewing your issue, I have determined the following:

    The event combiner will not cause you to "lose" events.  There is a register that flags which events occur - thus, even if you are in an ISR, there will still be a record of the event having occured (and not yet processed), and the ISR will be called at this point.  You can read more about this in chapter 9 here: http://www.ti.com/lit/ug/sprugw0b/sprugw0b.pdf

    If you did want to forgo the event combiner, you could use HWI_create.  There is an example of this under the "HWI" section here http://processors.wiki.ti.com/index.php/Configuring_Interrupts_on_Keystone_Devices

    I hope this helps.

    Sincerely,

    John Demery

  • Furthering on my previous post, this is how you could change Setup_Rx().  Note that this is only ONE of the interrupts.

    static Hwi_Handle hwiHandle = 0;

     

    int32_t Setup_Rx (NETIF_DEVICE*     ptr_net_device)

    {

                Hwi_Params hwiParams;

     

                …

    /* Register interrupts for the system event corresponding to the

                            * accumulator channel we are using.

                            */

                            /* System event n - Accumulator Channel 0 */

                            eventId             =   PLATFORM_ETH_EVENTID;

     

                            /* Pick a interrupt vector id to use */

                            vectId          =   PLATFORM_ETH_INTERRUPT;

                           

    /* manually create the Hwi */

    Hwi_Params_init(&hwiParams);

                            hwiParams.arg = (UArg)ptr_net_device;

                            hwiParams.eventId = eventId;

                            hwiParams.enableInt = TRUE;

     

                            hwiHandle = Hwi_create(vectId, (ti_sysbios_interfaces_IHwi_FuncPtr)EmacRxPktISR, &hwiParams, NULL);

                            if (!hwiHandle)

                            {

                                        platform_write ("Error registering HWI!\n");

                                        return -1;

                            }

                                       

                            platform_write ("Ethernet eventId : %d and vectId (Interrupt) : %d \n", eventId, vectId);

     

     

                            /* Register our ISR handle for this event – this gets commented out */

                            //EventCombiner_dispatchPlug (eventId, (EventCombiner_FuncPtr)EmacRxPktISR, (UArg)ptr_net_device, TRUE);

                            //EventCombiner_enableEvent(eventId);

     

                            /* Map the event id to hardware interrupt 7. */

                            //Hwi_eventMap(vectId, eventId >> 5);

     

                            /* Enable interrupt */

                            //Hwi_enableInterrupt(vectId);

    }

  • Thanks  for you reply. I have a try as you said, but the net does not work.

    And I just comment out the code below in .cfg:

    Ecm.eventGroupHwiNum[0] = 7;

    Ecm.eventGroupHwiNum[1] = 8;

    Ecm.eventGroupHwiNum[2] = 9;

    Ecm.eventGroupHwiNum[3] = 10;

    Is anything wrong ?

  • Hello, hopefully I can be a bit more helpful this time.

    Are you trying to run the helloworld ndk application?  Or are you trying to add your own functionality in addition to it?  Did the net and interrupts work before you commented out the above code?  Regardless of which one you are doing, you DO NOT have to comment out the event combiner code.  You will not lose events.  They will get flagged in an Event Flag Register (noted here http://processors.wiki.ti.com/index.php/Configuring_Interrupts_on_Keystone_Devices).  There should be no reason to get rid of the event combiner code.

    If you absolutely must get rid of the event combiner code, you can't simply comment it out.  You must then map the events to interrupts individually.  I provided a code example in my previous post which demonstrates how to do one of these events - not all of them.  You would have to follow similar format for all other events/interrupts you want.  If you are doing this in the setup_rx, you must make sure to rebuild the nimu application layer project.  You would have to import the nimu_eth_evm6678l from the PDK folder and rebuild that once the changes are made, then rebuild your project.

    Overall, if your concern is event loss - that won't happen with event combiner.  I would recommend leaving the event combiner as is.  I hope this helps.  

    -John Demery 

  • hello,

    I have a try follow you ! In the .cfg file:

    var Ecm = xdc.useModule ('ti.sysbios.family.c64p.EventCombiner'); //it is not commetted out

    //commen out below code ,if I do one to one map, below code will use 4 CPU interrupts,So I need comment it out!

    Ecm.eventGroupHwiNum[0] = 7;

    Ecm.eventGroupHwiNum[1] = 8;

     Ecm.eventGroupHwiNum[2] = 9;

     Ecm.eventGroupHwiNum[3] = 10;

    and in the setup_rx(), I do what you told me before!

    This time the net works! I have knew using event combiner will not loss event.

    I just want to one event map to one CPU ISR, So I don't want to use event combiner !

    1.I don't konw here why "var Ecm = xdc.useModule ('ti.sysbios.family.c64p.EventCombiner'); " will affect the CPU intterupt! A few days ago, I commetted out this code,net not work! Today I ucomment out it, the net works!

     

    2.So far I have used the CSL to config the interrupt, just using one event map to one CPU ISR, no combiner, and the CPU interrupt works OK! If I use the bios to configure the CPU  interrupt, achieve the  one to one map,  what  need I do?  I have a try,the below is the config!The interrupt don't work!

    Thanks very  much!

    Si

  •  I am sorry that  I have made a mistake, I just have a  test commentting out the code "var Ecm = xdc.useModule ('ti.sysbios.family.c64p.EventCombiner');" And  the 

    net work, Maybe I am not using the right nimu lib when I rebuild the lib project. So what you told me before is right, if I want to achieve   one event map to one CPU ISR,just using the code below,I map the IPC event to CPU 6 interrupt,using the IpcIsr as the ISR. after  the code below , I can get a IPC interrupt! I use this code in my C code, So if I want to use the bios to achieve it, How to do ,see the picture in my previous post ? Thanks!

     Hwi_Params params;

     Error_Block eb;

     

     

       // Initialize the error block

        Error_init(&eb);

        Hwi_Params_init(&params);

        params.eventId = CSL_GEM_IPC_LOCAL ;

        // The arg must be set to params.eventId.    

     params.arg = params.eventId;

        // Enable the interrupt.    

    params.enableInt = TRUE;

     Hwi_create(6, (ti_sysbios_interfaces_IHwi_FuncPtr)IpcIsr, &params, &eb);

     

  • I can't tell exactly what the issue is because I do not have your INT4_ISR function code.  Is there any particular reason you changed IpcIsr (from the c code) to INT4_ISR (from the sysbios screencap above)? 

    It looks like you are missing the "Argument passed to ISR function" field.  This is present in your c code, but not your sysbios.  See in your c code how you pass params to hwi_create?  These are the parameters that ultimately get passed to the ISR.  It is my guess that that your ISR isn't working because of the lacking arguments passed to it. 

    Is there any particular reason you'd like to do it in sysbios instead of the c code?

    Give the above suggestion of modifying the "Argument passed to ISR function" a try and let me know how that works.  If this still doesn't, it would be very helpful if you could attach your code so I could try things as well. 

    -John Demery

  • I've spent some time investigating the "logic" and hopefully I can now save some time for those who try to understand it.

    You actually need only 2 "magic" lines in you cfg script:

    Ecm.eventGroupHwiNum[0] = 7;

    Ecm.eventGroupHwiNum[1] = 8;

    The first line ensures Hwi7 (PLATFORM_ETH_INTERRUPT) will be 1) created and 2) dispatched via EventCombiner_dispatch().

    The second one ensures that event #1 (event combiner's output for events 32-63) is unmasked in the corresponding EVTMASKREG.

    During NIMU initialization Setup_Rx() performs as follows:

    1) It plugs the table used by EventCombiner_dispatch() with EmacRxPktISR() ISR; entry #48 (PLATFORM_ETH_EVENTID) of the table is plugged.

    2) It enables (i.e. unmasks) event #48 (PLATFORM_ETH_EVENTID) via corresponding EVTMASKREG.

    3) It REMAPS Hwi7 to event #1 (via INTRMUXREG1).

    Note that Hwi7 is not created here. That's why we need the first "magic" line.

    Also note that Hwi7 is triggered whenever event #1 (not event #48!) is flagged and event #1 was not deliberately unmasked here. That's why we need the second "magic" line.

    Finally, note that event #0 is not mapped to any interrupt from then onward even though in your cfg script you clearly wrote "Ecm.eventGroupHwiNum[0] = 7" (but who cares?)

    Now it's easy to see that you can replace the above "magic" lines with the following:

    Ecm.eventGroupHwiNum[1] = 7;

    You also can get rid of EventCombiner altogether - just patch the NIMU as was described by Jonh.

    I believe, the NIMU driver was written either by Einstein or by a damn fool