Quantcast
Channel: Processors forum - Recent Threads
Viewing all articles
Browse latest Browse all 17527

GPIO interrupt

$
0
0

 Hi All!

I want to get GPIO interrupt by external triger.


I configure McASP clk output for 12.8kHz on the pin, and it is works well. I routed by the wire McAsp clk pin to GP2[15].

Falling edge on GP2[15] should generate interrupt. In the interrupt routine should toggle GP2[12]. So finally I should see periodic signal on the GP2[12]. I read manual and investigated example projects.

On the GP2[15] I see 12.8kHz signal by the scope, but on the GP2[12] I see nothing.

Please look to my code of initialization bellow:

static void ConfigureIntGPIO(void)
{
	// Configure GPIO interrupts for ARM or DSP

	// Register the ISR in the Interrupt Vector Table
	IntRegister(C674X_MASK_INT4, GPIOIsr);

	// Map the system interrupt to the DSP maskable interrupt
	IntEventMap(C674X_MASK_INT4, SYS_INT_GPIO_B2INT);

	// Enable DSP maskable interrupt
	IntEnable(C674X_MASK_INT4);


}

static void GPIOIsr(void)
{
    /* Disable the interrupts for pins of bank 2 in GPIO.*/
    GPIOBankIntDisable(SOC_GPIO_0_REGS, 2);

    unsigned int res;
    	res = GPIOPinRead(SOC_GPIO_0_REGS, 45);
    	if(res == GPIO_PIN_LOW)
    		GPIOPinWrite(SOC_GPIO_0_REGS, 45, GPIO_PIN_HIGH);
    	else
    		GPIOPinWrite(SOC_GPIO_0_REGS, 45, GPIO_PIN_LOW);


    // Clear the system interrupt status in the DSPINTC
    IntEventClear(SYS_INT_GPIO_B2INT);


    /* Clears the Interrupt Status of GP2[15] in GPIO.*/
    GPIOPinIntClear(SOC_GPIO_0_REGS, 48);

    //GPIOBankIntEnable(SOC_GPIO_0_REGS, 2);
}


static void SetUpInt(void)
{
	// Setup the ARM or DSP interrupt controller
	// Initialize DSP interrupt controller
	IntDSPINTCInit();

	// Enable DSP interrupts globally
	IntGlobalEnable();

}

void hardware_init(void)
{
	/* The Local PSC number for GPIO is 3. GPIO belongs to PSC1 module.*/
	    PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_GPIO, PSC_POWERDOMAIN_ALWAYS_ON,
		     PSC_MDCTL_NEXT_ENABLE);

	/* Power up the McASP module */
	    PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_MCASP0, PSC_POWERDOMAIN_ALWAYS_ON,
			     PSC_MDCTL_NEXT_ENABLE);

    /* Pin Multiplexing of pin (GP2-10) 10 of GPIO Bank 2.*/
    GPIOBank2Pin15PinMuxSetup();
    GPIOBank2Pin12PinMuxSetup();
	
	    McASPPinMuxSetup();
	

	    McASPclk_start();

    /* Sets the pin 48(GP2[15]) as input for receive interrupt from external ADC.*/
    GPIODirModeSet(SOC_GPIO_0_REGS, 48, GPIO_DIR_INPUT);

    /* Sets the pin 45(GP2[12]) as output for CLK of external ADC.*/
   GPIODirModeSet(SOC_GPIO_0_REGS, 45, GPIO_DIR_OUTPUT);

    GPIOPinWrite(SOC_GPIO_0_REGS, 45, GPIO_PIN_LOW);

    /*
    ** Configure falling edge and falling edge triggers on pin 48 to generate
    ** an interrupt
    */
   GPIOIntTypeSet(SOC_GPIO_0_REGS, 48, GPIO_INT_TYPE_FALLEDGE);

    /* Enable interrupts for Bank 2.*/
   GPIOBankIntEnable(SOC_GPIO_0_REGS, 2);

    /* Configuring the AINTC to handle interrupts.*/
    SetUpInt();

    /* Configure GPIO interrupts */
    ConfigureIntGPIO();

	   // spiInit();

	   // edmaInit();

}

hardware_init() called in the main.c


Viewing all articles
Browse latest Browse all 17527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>