DSPRelated.com
Code

Interrupt.c - DSK6713 External Interruptions via GPIO

David Valencia February 2, 20111 comment Coded in C for the TI C67x

Interruption configuration file in Assembler language can be found in the other code snippet:

http://www.dsprelated.com/showcode/69.php

 

For great references, please visit:

http://e2e.ti.com/support/dsp/tms320c6000_high_performance_dsps/f/115/p/12571/170261.aspx#170261

and:

Interrupt Configuration Questions (many documents were useful to achieve this snippet)

http://e2e.ti.com/support/dsp/tms320c6000_high_performance_dsps/f/115/p/49947/179588.aspx#179588

 

Practice manual is in the following links:

SPANISH: http://www.box.net/shared/98nlf3zaj2

ENGLISH: (Coming soon!)

/* Interruption.c 
JOSE DAVID VALENCIA PESQUEIRA
UPIITA-IPN 
THIS PROGRAM DETECTS AN EXTERNAL INTERRUPTION ON A GPIO PIN*/ 

#include <stdio.h> 
#include <string.h> 
#include <stdlib.h> 
#include <time.h> 
#include <csl_gpio.h> 
#include <csl_gpiohal.h> 
#include <csl_irq.h> 

/* GLOBAL VARIABLES
The flags are marked as volatile, to tell the compiler
that these can be modified by an external event, avoiding
to put them on registers and rather putting them on RAM
so they're ready for immediate use
*/

volatile int startflag = 0; 

GPIO_Handle gpio_handle;  /* Handle for the GPIO */ 

// GPIO Registers configuration

GPIO_Config gpio_config = {          
	0x00000000,  
	// gpgc = Interruption passtrhrough mode and direct GPIO control mode
	0x0000FFFF, // gpen = All GPIO 0-15 pins enabled
	0x00000000, // gdir = All GPIO pins as inputs
	0x00000000, // gpval = Stores logical level of pins
	0x00000010, // IRQ enable for pin 4
	0x00000010, // Enable Event for pin 4
	0x00000000  // gppol -- default state  
}; 

irq_ext_enable(){ 
	/* First, globally disable interruptions
	in the CSR (Control Status Register).
	Bit 0 is the GIE (Global Interrupt Enable)*/
	CSR = (CSR)&(0xFFFFFFFE); 
	// Enable NMIE bit in the IER (bit 1)
	IER |= 0x00000002; 
	// Enable INT4 bit in the IER (4th bit)
	IER |= 0x00000010; 
	// Finally, globally enable interruptions in the CSR
	CSR |= 0x00000001; 
} 

main() 
{      
	// To configure the GPIO
	gpio_handle = GPIO_open( GPIO_DEV0, GPIO_OPEN_RESET ); 
	GPIO_config(gpio_handle,&gpio_config); 
	irq_ext_enable(); 
	comm_intr();      //init DSK 
	DSK6713_LED_init(); 
	while(startflag == 0);  
	printf(“La interrupción externa encendió el led 3 del dsk6713\n”); 
	while(1) // Infinite While
}    

interrupt void c_int04()           //ISR 
{ 
	startflag = 1; 
	iter = 0; 
	DSK6713_LED_on(0);   //To turn on the led
}