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.

Compiler/TMS320C5535: REGISTERS INTERRUPT

Part Number: TMS320C5535

Tool/software: TI C/C++ Compiler

Hallo, 

I use the board ezdsp5535 and followed the "CSL_GPIO_InputPinExample".

I have a question.

I used the GPIO REGISTERS, in order to generate INTERRUPT on the pin -GPIO10  AND GPIO11.

When the interrupt is active on the pin GPIO10, must display a text on the LCD  OR  if the interrupt is active on the pin GPIO11, must display another text on the LCD.


1. HOW TO USE 2 INTERRUPTS IN THE SAME PROGRAM???

2. HOW TO CONFIGURE THE PINS (GPIO10 AND GPIO11)?? - IN THE SAME FUNCTIONS ("int gpio_input_int_test(void)")??? 

-OR I HAVE TO CREATE DIFFERENT FUNCTIONS IN ORDER TO CONFIGURE THEM???

I attached my program bellow.

Thank you so much!!!

Cristina

/*   TEST DESCRIPTION:
 *		This example code tests the GPIO(General Purpose Input Output) pin
 * functionality as input pin.
 * C5505/C5515 DSP is having 32 GPIO pins which can be configured as input or
 * output. GPIO pin 11 is configured as input pin by this test code.
 * For verifying the input functionality, a source is required which sends data
 * to the GPIO pin configured as input pin. GPIO pin 4 is configured as output
 * pin and is used as data source for pin 11. These two pins should be connected
 * with a jumper on the EVM to facilitate the data loop back. Interrupts are
 * enabled for the GPIO input pin to indicate the high signal on the input pin.
 * A data value 1 is written to the GPIO pin4 which is loop backed to the pin11
 * and is read in the ISR. Test will be successful when the GPIO interrupt for
 * pin11 is generated. Value read from the pin11 is also compared with the value
 * written to the pin4 to announce the success of the test. */

#include "ezdsp5535.h"
#include "ezdsp5535_led.h"
#include "csl_gpio.h"
#include "csl_intc.h"
#include "ezdsp5535_lcd.h"
#include <stdio.h>
#include <csl_general.h>
#include <string.h>



#define CSL_TEST_FAILED    (-1)
#define CSL_TEST_PASSED    (0)


/* Global Structure Declaration */
extern CSL_GpioObj     GpioObj;
extern CSL_GpioObj     *hGpio;
//int             i = 0;
Uint16          readVal = 0;

Uint16 led = FALSE;
int pin_int = 0;	//intrerupere activa pe pinul x


/* Reference the start of the interrupt vector table */
/* This symbol is defined in file vectors.asm       */
extern void VECSTART(void);


/* GPIO Interrupt Service Routine */
interrupt void gpioISR(void);


/* Function to test the functionality of GPIO as input pin
 *  This function configures GPIO pin 11 as input pin and pin 4 as output pin
 *  A data value is written to pin4 and is read from pin11. Both the values are
 *  compared and the result is returned to the main function. */
int gpio_input_int_test(void);


/*afisarea lcd*/ 
void oled_display(void);
    
volatile Int16 PaSs_StAtE = 0x0001; 
volatile Int16 PaSs = 0x0000; 

  
void main(void)
{
	int result;
	unsigned int *p = (unsigned int*)0x1C17;
	 
    EZDSP5535_LED_init();
    EZDSP5535_XF_toggle();
    EZDSP5535_init( );
     
   
    *p = 0x0F3F;
     
    printf("CSL GPIO Input Pin Test!\n\n");
    
    
    
    /* To test GPIO channel (pin) as an input channel in interrupt mode	*/
    result = gpio_input_int_test();
    if(CSL_TEST_PASSED == result)
    {
        printf("\nCSL GPIO Input Pin Test Passed!!\n");
    }
	else
	{
		printf("\nCSL GPIO Input Pin Test Failed!!\n");
  
        PaSs_StAtE = 0x0000; 
  
	}
  
        PaSs = PaSs_StAtE; 
           
           
             	
	while(1){}
	
}//ENDMAIN



int gpio_input_int_test(void)
{
    CSL_Status           status;
    CSL_GpioPinConfig    config;

	
    /* Pin muxing for GPIO 11 Pin */
    CSL_FINST(CSL_SYSCTRL_REGS->EBSR, SYS_EBSR_SP1MODE, MODE2);

    /* Disable CPU interrupt */
    IRQ_globalDisable();

	/* Clear any pending interrupts */
	IRQ_clearAll();

	/* Disable all the interrupts */
	IRQ_disableAll();

    /* Initialize Interrupt Vector table */
    IRQ_setVecs((Uint32)(&VECSTART));

	/* Open GPIO module */
    hGpio = GPIO_open(&GpioObj,&status);
    if((NULL == hGpio) || (CSL_SOK != status))
    {
        printf("GPIO_open failed\n");
        return(CSL_TEST_FAILED);
    }
    else
    {
		printf("GPIO_open Successful\n");
	}

	/* Reset the GPIO module */
    GPIO_reset(hGpio);



//----------------------GPIO11 INTERRUPT------------------------
    /** test GPIO_config API to make PIN11 as i/p */
	config.pinNum    = CSL_GPIO_PIN11;
    config.direction = CSL_GPIO_DIR_INPUT;
    config.trigger   = CSL_GPIO_TRIG_RISING_EDGE;
    status = GPIO_configBit(hGpio,&config);
	if(CSL_SOK != status)
	{
		printf("test failed - GPIO_configBit\n");
		return(CSL_TEST_FAILED);
	}
	else
	{
		printf("GPIO PIN11 is configured as Input Pin\n");
	}

	/* Enable GPIO interrupts */
    status = GPIO_enableInt(hGpio,CSL_GPIO_PIN11);
	if(CSL_SOK != status)
	{
		printf("test failed- GPIO_enableInt\n");
		return(CSL_TEST_FAILED);
	}

	//----------------------GPIO10 INTERRUPT------------------------
	config.pinNum    = CSL_GPIO_PIN10;
    config.direction = CSL_GPIO_DIR_INPUT;
    config.trigger   = CSL_GPIO_TRIG_RISING_EDGE;
    status = GPIO_configBit(hGpio,&config);


	/* Enable GPIO interrupts */
    status = GPIO_enableInt(hGpio,CSL_GPIO_PIN10);
	
	

	/* Clear any pending Interrupt */
    IRQ_clear(GPIO_EVENT);

    IRQ_plug(GPIO_EVENT,&gpioISR);
   

     /* Enabling Interrupt */
    IRQ_enable(GPIO_EVENT);
    IRQ_globalEnable();



    printf("GPIO ISR is called\n");

    if(readVal == 1)
    {
		printf("Reading Value from GPIO Pin11 is successful\n");
	}
	else
	{
		printf("Reading Value from GPIO Pin11 is Failed\n");
   
        PaSs_StAtE = 0x0000; 
	}

	return(CSL_TEST_PASSED);
}

interrupt void gpioISR(void)
{
	unsigned int *input_val = (unsigned int*)0x1C08;

	
	if(input_val[0] & 0x0800) 	pin_int = 11;
	if(input_val[0] & 0x0400)	pin_int = 10;
	 
      
        /* Clear GPIO Interrupt Flag Register */
       GPIO_clearInt(hGpio,CSL_GPIO_PIN10);
       GPIO_clearInt(hGpio,CSL_GPIO_PIN11);
       
       oled_display();
       
           

}







void oled_display(void)
 {
	 Int16 i=0;

	/* Initialize OLED display */
    EZDSP5535_OSD9616_init( );
    
    EZDSP5535_OSD9616_send(0x00,0x2e);  // Deactivate Scrolling
    
    
     /*-------------------PAGE 0--------------------*/
    
    /* Fill page 0 */ 
    EZDSP5535_OSD9616_send(0x00,0x00);   // Set low column address
    EZDSP5535_OSD9616_send(0x00,0x10);   // Set high column address
    EZDSP5535_OSD9616_send(0x00,0xb0+0); // Set page for page 0 to page 5
    
    for(i=0;i<128;i++)
    {
        EZDSP5535_OSD9616_send(0x40,0x00);
    }
    
    /* Write to page 0 */
    EZDSP5535_OSD9616_send(0x00,0x00);   // Set low column address
    EZDSP5535_OSD9616_send(0x00,0x10);   // Set high column address
    EZDSP5535_OSD9616_send(0x00,0xb0+0); // Set page for page 0 to page 5
      
    for(i=0;i<50;i++)
    {
        EZDSP5535_OSD9616_send(0x40,0x00);  // Spaces
    }
    
	if(pin_int == 11)
	{
		 /*Display the VALUE*/
      EZDSP5535_OSD9616_printLetter(0x31,0x49,0x49,0x2F);  // 5
      EZDSP5535_OSD9616_printLetter(0xE0,0x60,0x00,0x00);  // ,
      EZDSP5535_OSD9616_printLetter(0x36,0x49,0x49,0x22);  // 3
      printf("GPIO11\n");
	}
	if (pin_int == 10)
	{
		 /*Display the VALUE*/
      EZDSP5535_OSD9616_printLetter(0xFF,0xFF,0xFF,0xFF);  // 5
      EZDSP5535_OSD9616_printLetter(0xE0,0x60,0x00,0x00);  // ,
      EZDSP5535_OSD9616_printLetter(0xFF,0xFF,0xFF,0xFF);  // 3
      printf("GPIO10\n");
	}
	else
	{
		EZDSP5535_OSD9616_printLetter(0x00,0x00,0x00,0x00);  // 5
      	EZDSP5535_OSD9616_printLetter(0x00,0x00,0x00,0x00);  // ,
      	EZDSP5535_OSD9616_printLetter(0x00,0x00,0x00,0x00);  // 3
      	printf("NAN\n");
	}
	
     

}//END_OLEDTEST

  • Hi,

    I've notified the sw team. They will post their feedback directly here.

    Best Regards,
    Yordan
  • Hi Cristina,

    You can use as reference /c55_lp/c55_csl_3.08/demos/audio-preprocessing/c5517/AudioCodec_DMA.c demo project.

    BR
    Tsvetolin Shulev
  • Hallo Tsvetolin S.,

    Thank you so much for your suggestion. I resolved this problem, but I have another and namely:

    I use these interrupts in my program and inside them I want to start a timer for the countering the rectangular pulses that come on the GPIO10 or GPIO11.

    (these pulses that come on the GPIO10 or GPIO11 active these interrupts!!! )

    The interrupts are activated but the timer doesn`t start counting. I don`t know why??? 

    In the attachement is my program.

    Thank you!!!

    Cristina

    #include "ezdsp5535.h"
    #include "ezdsp5535_led.h"
    #include "csl_gpio.h"
    #include "csl_intc.h"
    #include "csl_gpt.h"
    #include "ezdsp5535_lcd.h"
    #include <stdio.h>
    #include <csl_general.h>
    #include <string.h>
    
    
    extern void VECSTART(void);
    
    volatile Uint16    hitIsr = 0;
    
    #define CSL_TEST_FAILED    (-1)
    #define CSL_TEST_PASSED    (0)
    
    
    /* Global Structure Declaration */
    extern CSL_GpioObj     GpioObj;
    extern CSL_GpioObj     *hGpio;
    
    
    /* Reference the start of the interrupt vector table */
    /* This symbol is defined in file vectors.asm       */
    extern void VECSTART(void);
    
    
    /* GPIO Interrupt Service Routine */
    interrupt void gpioISR(void);
    
    
    /* Function to test the functionality of GPIO as input pin
     *  This function configures GPIO pin 11 and pin 10 as input pin */
    int gpio_input_int_test(void);
    
        
    volatile Int16 PaSs_StAtE = 0x0001; 
    volatile Int16 PaSs = 0x0000; 
    
      
    void main(void)
    {
    	int result;
    	unsigned int *p = (unsigned int*)0x1C17;
    	
    	
        EZDSP5535_LED_init();
        EZDSP5535_XF_toggle();
       
        *p = 0x0F3F;
         
        printf("CSL GPIO Input Pin Test!\n\n");
           
    
        /* To test GPIO channel (pin) as an input channel in interrupt mode	*/
        result = gpio_input_int_test();
        if(CSL_TEST_PASSED == result)
        {
            printf("\nCSL GPIO Input Pin Test Passed!!\n");
        }
    	else
    	{
    		printf("\nCSL GPIO Input Pin Test Failed!!\n");
      
            PaSs_StAtE = 0x0000; 
      
    	}
      
            PaSs = PaSs_StAtE; 
               
    	while(1)
    	{
    			
    	}
    	
    }//ENDMAIN
    
    
    int gpio_input_int_test(void)
    {
    /*--------------------DECLARATIONS-------------------*/ 
        CSL_Status           status;
        CSL_GpioPinConfig    config;		
    	CSL_GptObj	         gptObj;
        CSL_Handle	         hGpt;
    	CSL_Config 	         hwConfig;
    	hitIsr = FALSE;
    	status = 0;
    	//Uint16               looper;
    	
     /*-----------CONFIGURATION FOR THE GPIO--------------*/ 
    	
        /* Pin muxing for GPIO 4 and 11 Pin */
        CSL_FINST(CSL_SYSCTRL_REGS->EBSR, SYS_EBSR_SP1MODE, MODE2);
    
        /* Disable CPU interrupt */
        IRQ_globalDisable();
    
    	/* Clear any pending interrupts */
    	IRQ_clearAll();
    
    	/* Disable all the interrupts */
    	IRQ_disableAll();
    
        /* Initialize Interrupt Vector table */
        IRQ_setVecs((Uint32)(&VECSTART));
    
    	/* Open GPIO module */
        hGpio = GPIO_open(&GpioObj,&status);
        if((NULL == hGpio) || (CSL_SOK != status))
        {
            printf("GPIO_open failed\n");
            return(CSL_TEST_FAILED);
        }
        else
        {
    		printf("GPIO_open Successful\n");
    	}
    
    	/* Reset the GPIO module */
        GPIO_reset(hGpio);
    
    	/* GPIO_config API to make PIN10 as i/p pin */
    	config.pinNum    = CSL_GPIO_PIN10;
        config.direction = CSL_GPIO_DIR_INPUT;
        config.trigger   = CSL_GPIO_TRIG_CLEAR_EDGE;
        status = GPIO_configBit(hGpio,&config);
    	if(CSL_SOK != status)
    	{
    		printf("test failed - GPIO_configBit\n");
    		return(CSL_TEST_FAILED);
    	}
    	else
    	{
    		printf("GPIO PIN10 is configured as Input Pin\n");
    	}
    
        /* GPIO_config API to make PIN11 as i/p */
    	config.pinNum    = CSL_GPIO_PIN11;
        config.direction = CSL_GPIO_DIR_INPUT;
        config.trigger   = CSL_GPIO_TRIG_RISING_EDGE;
        status = GPIO_configBit(hGpio,&config);
    	if(CSL_SOK != status)
    	{
    		printf("test failed - GPIO_configBit\n");
    		return(CSL_TEST_FAILED);
    	}
    	else
    	{
    		printf("GPIO PIN11 is configured as Input Pin\n");
    	}
    
    
    	/* Enable GPIO interrupts */
    	
    	status = GPIO_enableInt(hGpio,CSL_GPIO_PIN10);
    	if(CSL_SOK != status)
    	{
    		printf("test failed- GPIO_enableInt\n");
    		return(CSL_TEST_FAILED);
    	}
    	
    		
        status = GPIO_enableInt(hGpio,CSL_GPIO_PIN11);
    	if(CSL_SOK != status)
    	{
    		printf("test failed- GPIO_enableInt\n");
    		return(CSL_TEST_FAILED);
    	}
    
    
    	/* Clear any pending Interrupt */
        IRQ_clear(GPIO_EVENT);
    
        IRQ_plug(GPIO_EVENT,&gpioISR);
    
    
         /* Enabling Interrupt */
        IRQ_enable(GPIO_EVENT);
        IRQ_globalEnable();
    
        printf("GPIO ISR is called\n"); 
      
     /*-----------THE CONFIGURATION FOR THE TIMERS--------------*/ 
    		
    		/* Open the CSL GPT module */
    	hGpt = GPT_open (GPT_1, &gptObj, &status);
    	if((NULL == hGpt) || (CSL_SOK != status))
    	{
    		printf("GPT Open Failed\n");
    		return (CSL_TEST_FAILED);
    	}
    	else
    	{
    		printf("GPT Open Successful\n");
    	}
    
    	/* Reset the GPT module */
    	status = GPT_reset(hGpt);
    	if(CSL_SOK != status)
    	{
    		printf("GPT Reset Failed\n");
    		return (CSL_TEST_FAILED);
    	}
    	else
    	{
    		printf("GPT Reset Successful\n");
    	}
    
    	/* Configure GPT module */
    	hwConfig.autoLoad 	 = GPT_AUTO_ENABLE;
    	hwConfig.ctrlTim 	 = GPT_TIMER_ENABLE;
    	hwConfig.preScaleDiv = GPT_PRE_SC_DIV_0;
    	hwConfig.prdLow 	 = 0xFFFF;
    	hwConfig.prdHigh 	 = 0x0000;
    
    	status =  GPT_config(hGpt, &hwConfig);
    	if(CSL_SOK != status)
    	{
    		printf("GPT Config Failed\n");
    		return (CSL_TEST_FAILED);
    	}
    	else
    	{
    		printf("GPT Config Successful\n");
    	}
    		
    	/*---------END FOR TIMER-------*/
    	
    	return(CSL_TEST_PASSED);
    	
    }//END_gpio_input_int_test
    
    
    interrupt void gpioISR(void)
    {	
    	
    	/*------------DECLARATIONS----------*/
         Uint32    timeCnt1;
           
    	 CSL_Status                     status_int11;
    	 CSL_Status                     status_int10;
    	 
    	 volatile CSL_GptObj	        gptObj;
         volatile CSL_Handle	        hGpt;
    	 volatile CSL_Status 	        status;
    	 volatile CSL_Config 	        hwConfig; 
       
         hitIsr = FALSE;
    	 status = 0;
         timeCnt1 = 0;
    	
    	  	
    	/*---------------INTERRUPTS-------------*/ 		
     	if((1 == GPIO_statusBit(hGpio,CSL_GPIO_PIN11,&status_int11)))
        {
        	
    	}//ENDIF
          
        else if((1 == GPIO_statusBit(hGpio,CSL_GPIO_PIN10,&status_int10)))
        {
    
    	      if(!GPT_start(hGpt))	//if timer is off, I want to start it   
    	  	 	{
    		   		/* Start the Timer 1 */
    		   		status=GPT_start(hGpt);
    		   		
    		   		if(CSL_SOK != status)
    				{
    					printf("\nGPT Start Failed\n");					
    				}		   
    		    
    	  		 }//endif
    	   	
    	     if(GPT_start(hGpt))	//if timer is on, I want to stoped it  
    	  		{
    			
    		   	/* Stop The Timer */
    		   	status = GPT_stop(hGpt);
    		   	if(CSL_SOK != status)
    			{
    				printf("GPT Stop Failed \n");
    				
    			}
    			else
    			{
    				printf("GPT Stop Successful\n");
    			}
    			
    		   	/* READ THE TIMER COUNT!!! */
    		    status = GPT_getCnt(hGpt, &timeCnt1);
    		   
    		    if(CSL_SOK != status)
    			{
    	 			printf("GPT Count-1 Failed \n");
    			
    			}	
    			else
    			{
    				printf("GPT Count-1 Successful\n");
    			}
    		    
    		
    		   /* RESET THE TIMER COUNT TO ZERO */
    		    status = GPT_reset(hGpt);
    			
    		    printf("\n Reset Timer 1!\n");
    		  				     
    	 	    }//ENDIF
    	
    	    
        }//ENDELSEIF
        
    
          /* Clear GPIO Interrupt Flag Register */
         GPIO_clearInt(hGpio,CSL_GPIO_PIN11);
     	 GPIO_clearInt(hGpio,CSL_GPIO_PIN10);
    }//end_function