GPIO interrupt handling issue

Hello,

I am using ADSP SC 587 custom board. We want to use two SHARC cores (SHARC0 and SHARC1) simultaneously for our processing.

So for this we are giving external interrupts to both cores, using GPIO pins. Odd interrupts in SHARC 0 and Even interrupts in SHARC 1.

While handling interrupt we are able to handle  interrupt only in a single core. Interrupts are handled while running both cores individually. But not while running core simultaneously.

Please resolve the issue. Attaching the GPIO code for your reference. 

Parents
  • Unable to attach file

     */
    #include<gpio.h>
    
    #define GPIO_MEMORY_SIZE (ADI_GPIO_CALLBACK_MEM_SIZE*2)
    static uint8_t gpioMemory[GPIO_MEMORY_SIZE];
    static int g_intr_count = 0;
    /* ISR for interrupt received from FPGA */
    static cycle_stats_t cycles;
    void gpioCallback(ADI_GPIO_PIN_INTERRUPT ePinInt, uint32_t Data, void *pCBParam)
    {
    	g_intr_count++;
    	PRINTF("GPIO Interrupt %d received in DSP core-%d", g_intr_count, adi_core_id());
    	xSemaphoreGiveFromISR(Gpio_Semaphore, NULL);
    }
    
    static int CheckResult(ADI_GPIO_RESULT result)
    {
        if (result != ADI_GPIO_SUCCESS) {
            return -1;
        }
        return 0;
    }
    
    int gpio_init()
    {
        uint32_t gpioMaxCallbacks;
        ADI_GPIO_RESULT result;
    
    	if(ADI_CORE_SHARC0 == adi_core_id())
    	{
    		 /* initialize the GPIO service */
    		result = adi_gpio_Init((void*)gpioMemory , GPIO_MEMORY_SIZE, &gpioMaxCallbacks);
    		if (CheckResult(result) == -1)
    		{
    				return -1;
    		}
    		/* set GPIO input */
    		result = adi_gpio_SetDirection(ADI_GPIO_PORT_F, ADI_GPIO_PIN_14, ADI_GPIO_DIRECTION_INPUT);
    		if (CheckResult(result) == -1)
    				return -1;
    
    		/* set input edge sense */
    		result = adi_gpio_SetPinIntEdgeSense(ADI_GPIO_PIN_INTERRUPT_4, ADI_GPIO_PIN_14, ADI_GPIO_SENSE_RISING_EDGE);
    		if (CheckResult(result) == -1)
    				return -1;
    
    		/* register gpio callback */
    		result = adi_gpio_RegisterCallback(ADI_GPIO_PIN_INTERRUPT_4, ADI_GPIO_PIN_14, gpioCallback, (void*) 0);
    		if (CheckResult(result) == -1)
    			return -1;
    
    		/* enable interrupt mask */
    		result = adi_gpio_EnablePinInterruptMask(ADI_GPIO_PIN_INTERRUPT_4, ADI_GPIO_PIN_14, true);
    		if (CheckResult(result) == -1)
    			return -1;
    	}
    #if 1
        else if(ADI_CORE_SHARC1 == adi_core_id())
        {
        	/* initialize the GPIO service */
    		result = adi_gpio_Init((void*)gpioMemory , GPIO_MEMORY_SIZE, &gpioMaxCallbacks);
    		if (CheckResult(result) == -1)
    		{
    				return -1;
    		}
        	//...............core 2 gpio configuration.................//
           /* set GPIO input */
    		result = adi_gpio_SetDirection(ADI_GPIO_PORT_F,	ADI_GPIO_PIN_0, ADI_GPIO_DIRECTION_INPUT);
    		if (CheckResult(result) == -1)
    			return -1;
    
    		/* set input edge sense */
    		result = adi_gpio_SetPinIntEdgeSense(ADI_GPIO_PIN_INTERRUPT_4, ADI_GPIO_PIN_0, ADI_GPIO_SENSE_RISING_EDGE);
    		if (CheckResult(result) == -1)
    			return -1;
    
    		/* register gpio callback */
    		result = adi_gpio_RegisterCallback(ADI_GPIO_PIN_INTERRUPT_4, ADI_GPIO_PIN_0, gpioCallback, (void*) 0);
    		if (CheckResult(result) == -1)
    			return -1;
    
    		/* enable interrupt mask */
    		result = adi_gpio_EnablePinInterruptMask(ADI_GPIO_PIN_INTERRUPT_4, ADI_GPIO_PIN_0, true);
    		if (CheckResult(result) == -1)
    			return -1;
        }
       Gpio_Semaphore = xSemaphoreCreateBinary();
       if( Gpio_Semaphore == NULL )
       {
    	   printf("ERROR : Insufficient heap available for Semaphore\n");
    	   return -1;
       }
    #endif
           return 0;
    }
    

  • 0
    •  Analog Employees 
    on Sep 10, 2019 12:20 PM over 1 year ago in reply to GBiswal462

    Hello,

    Please find the attached example code for handling interrupts in both cores simultaneously using GPIO. In this code, we have used two different PINT modules (ADI_GPIO_PIN_INTERRUPT_4 and ADI_GPIO_PIN_INTERRUPT_5) for registering callbacks.

    If you are still facing the issue, please mail your project to processor.tools.support@analog.com.  

    Best Regards,
    Santha kumari.K

    GPIO_Interrupt.zip

  • Thanks for your reply.

    --> I want to know how did you choose two different PINT modules

    --> In GPIO_Core2.h 

           /* GPIO pin within the port to which push button 1 is connected to */
           #define PUSH_BUTTON2_PIN (ADI_GPIO_PIN_1)

           /* pin within the pint to which push button 1 is connected to */
           #define PUSH_BUTTON2_PINT_PIN (ADI_GPIO_PIN_17)

    why the two pins are different in GPIO_core2.h but in GPIO_core1.h these two pins are same.

    Please help . Its urgent.

    Regards,

    GBiswal

  • +1
    •  Analog Employees 
    on Sep 11, 2019 1:10 PM over 1 year ago in reply to GBiswal462

    Hello,

    Please find the details here

    --> I want to know how did you choose two different PINT modules
    >>
    Please note that if you are registering two callback functions for same interrupt ID (For Eg: ADI_GPIO_PIN_INTERRUPT_4), the latest one will overwrite the previously registered callback function. So that one of the core is working but it will not work for both cores

    If you are using two different PINT modules, then you can register two callback function i.e., one in Core1 and another one in Core2. So that we have used two different PINT modules.

    --> why the two pins are different in GPIO_core2.h but in GPIO_core1.h these two pins are same.
    >>

    In GPIO_Core2.h, we are using ADI_GPIO_PIN_INTERRUPT_5 (PINT5 Module). As the push button PB2 is connected with PF_01, it is associated with PFL (POrtF Lower). In PINT5 module (32-bit register), PFL is assigned to BYTE2 (Bit 16 to 23). So we have to register callback function for ADI_GPIO_PIN_INTERRUPT_5 (PINT5 Module) and the pin (the PB2 connected with PIN1 so Bit 17) within the pint to which PB2 is connected.

    For more information about PIN module, please refer the chapter 'PORT Event Control' in the below ADSP-SC58x HRM:
    www.analog.com/.../SC58x-2158x-hrm.pdf

    Regards,
    Santha kumari.K

Reply
  • +1
    •  Analog Employees 
    on Sep 11, 2019 1:10 PM over 1 year ago in reply to GBiswal462

    Hello,

    Please find the details here

    --> I want to know how did you choose two different PINT modules
    >>
    Please note that if you are registering two callback functions for same interrupt ID (For Eg: ADI_GPIO_PIN_INTERRUPT_4), the latest one will overwrite the previously registered callback function. So that one of the core is working but it will not work for both cores

    If you are using two different PINT modules, then you can register two callback function i.e., one in Core1 and another one in Core2. So that we have used two different PINT modules.

    --> why the two pins are different in GPIO_core2.h but in GPIO_core1.h these two pins are same.
    >>

    In GPIO_Core2.h, we are using ADI_GPIO_PIN_INTERRUPT_5 (PINT5 Module). As the push button PB2 is connected with PF_01, it is associated with PFL (POrtF Lower). In PINT5 module (32-bit register), PFL is assigned to BYTE2 (Bit 16 to 23). So we have to register callback function for ADI_GPIO_PIN_INTERRUPT_5 (PINT5 Module) and the pin (the PB2 connected with PIN1 so Bit 17) within the pint to which PB2 is connected.

    For more information about PIN module, please refer the chapter 'PORT Event Control' in the below ADSP-SC58x HRM:
    www.analog.com/.../SC58x-2158x-hrm.pdf

    Regards,
    Santha kumari.K

Children
  • Hello,

    Thanks for your reply.

    I have some doubts.

    1) PF_01 is associated with PFL, but how to know that it is assigned to BYTE0 or BYTE2?

    2) I want to handle interrupts in both SHARC cores (For SHARC0 interrupt in PF_14  and for SHARC1  interrupt in PF_00). How to assign PINT and pins to PINT?

    Regards,

    GBiswal

  • +1
    •  Analog Employees 
    on Sep 16, 2019 11:06 AM over 1 year ago in reply to GBiswal462

    Hello Biswal,

    Please find answers for your queries here

    1) PF_01 is associated with PFL, but how to know that it is assigned to BYTE0 or BYTE2?

    ANS>>

    As shown in the above PINTx Block Diagram (PINT_Block.JPG), each port is subdivided into two 8-pin half ports, upper (PxH) and lower(PxL). The PINT_ASSIGN registers control the 8-bit multiplexers associated with these half ports, where the lower half units (eight pins) can be forwarded to either byte 0 or byte 2 of the PINTx blocks, and the upper half units (eight pins) can be forwarded to either byte 1 or byte 3 of the PINTx blocks.

    By default, Byte 2 is mapped with PF_L and Byte 0 is mapped with PG_L in the PINT_Assign Register. Refer PINT_ASSIGN.JPG.


    2) I want to handle interrupts in both SHARC cores (For SHARC0 interrupt in PF_14  and for SHARC1  interrupt in PF_00). How to assign PINT and pins to PINT?

    ANS>>

    As you are registering callbacks in both the cores, you have to use two different modules. So you can use PINT4 and PINT5.

    PF_H (8 to 15) is mapped with Byte1 by default in PINT4 module. So you have to register callback function for ADI_GPIO_PIN_INTERRUPT_4 (PINT4 Module) and the pin 14 (PF_14 so Bit 14).

    Similarly for PF_00, PF_L is mapped to BYTE2 in PINT5 module. So you have to register callback function for ADI_GPIO_PIN_INTERRUPT_5 (PINT5 Module) and the pin 16 (PF_00 so Bit 16).

    Regards,
    Santha kumari.K

  • Hello

    Thanks for your reply. Now we are able to handle both interrupts in both SHARC core. 

    Now we are using PF_12 for interrupt to ARM . Before we are giving interrupts to SHARC cores(PF_!4 and PF_00) . While ARM and SHARC both are running individually we are able to handle interrupt in ARM side.

    But while using both ARM and SHARC we are unable to handle interrupt in ARM side(linux). Below message is coming in console.

    [ 142.470708] IRQ_NOPROBE set
    [ 142.476781] IRQ_NOREQUEST set
    [ 142.482855] unexpected IRQ trap at vector 00
    [ 142.491374] irq 0, desc: dc403040, depth: 1, count: 0, unhandled: 0
    [ 142.503849] ->handle_irq(): c0042c10, handle_bad_irq+0x0/0x270
    [ 142.515648] ->irq_data.chip(): c04c1f98, 0xc04c1f98
    [ 142.525364] ->action(): (null)

    Regards,

    GBiswal

  • 0
    •  Analog Employees 
    on Oct 14, 2019 12:09 PM over 1 year ago in reply to GBiswal462

    Hello Biswal,

    We can able to use interrupts in both ARM and SHARC core for Windows Operating System.

    Please note that Linux related questions are handled in the Engineer Zone via "Linux for ADSP-SC5xx processors" community.

    We would request you to post your query in the below Linux for SC5xx EngineerZone community

    ez.analog.com/.../

    Regards,
    Santha kumari.K