DSPRelated.com
Forums

gpio init

Started by msha...@yahoo.com February 20, 2008
Hi all,
I am working with MATLAB/Simlink Embedded Target for C6000 to try and
prgoram my C6713 DSP but would like to know how to program my GPIO
pins? please give me some basics to point me in the right
direction.
Thanks
Maryam
Check Out Industry's First Single-Chip, Multi-Format, Real-Time HD Video Transcoding Solution for Commercial & Consumer End Equipment: www.ti.com/dm6467
Hi,

I have provided u below a sample code from TI for C6000 application to
configure the GPIO pins, u can modify for ur program.

/* Global Declaration */

GPIO_Handle myGPIO_handle; /* GPIO handle */

Then u need configure the GPIO pins

GPIO_Config MyConfig = { 0x00000000, /* gpgc */

0x00000000, /* gpen --

0x00000000, /* gdir -

0x00000000, /* gpval */

0x00000000, /* gphm all interrupts disabled for io pins */

0x00000000, /* gplm all interrupts to cpu or edma disabled */

0x00000000 /* gppol -- default state */

};

myGPIO_handle = GPIO_open( GPIO_DEV0, GPIO_OPEN_RESET );

GPIO_config(myGPIO_handle , &MyConfig );

Try this out

Regards

Thiya

________________________________

From: c... [mailto:c...] On Behalf Of
m...@yahoo.com
Sent: Wednesday, February 20, 2008 12:32 PM
To: c...
Subject: [c6x] gpio init

Hi all,
I am working with MATLAB/Simlink Embedded Target for C6000 to try and
prgoram my C6713 DSP but would like to know how to program my GPIO
pins? please give me some basics to point me in the right
direction.
Thanks
Maryam
I use the below code on our company's 6412 board. Board has a PCI interface and the two GPIO interrupts below, GPIO_PIN4 and GPIO_PIN5, are use as interrupts from two high capacity FIFO UARTs.

These bits are assigned interrupt processors in the .cdb. The other GPIO_PINs are used in development.

// Set up general input pins for interrupts.
hGpio = GPIO_open(GPIO_DEV0,GPIO_OPEN_RESET);
/* Enables pins */
GPIO_pinEnable (hGpio,GPIO_PIN0| GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN4 | GPIO_PIN5 );

/* Sets Pin0, Pin1, and Pin2 as an output pins. */
Current_dir = GPIO_pinDirection(hGpio,GPIO_PIN0, GPIO_OUTPUT);
Current_dir = GPIO_pinDirection(hGpio,GPIO_PIN1, GPIO_OUTPUT);
Current_dir = GPIO_pinDirection(hGpio,GPIO_PIN2, GPIO_OUTPUT);

if( hGpio != NULL ) GPIO_pinWrite( hGpio, GPIO_PIN0, 0 );
if( hGpio != NULL ) GPIO_pinWrite( hGpio, GPIO_PIN1, 0 );

/* Sets Pin4, and Pin5 as input pins. */
Current_dir = GPIO_pinDirection(hGpio,GPIO_PIN4, GPIO_INPUT);
Current_dir = GPIO_pinDirection(hGpio,GPIO_PIN5, GPIO_INPUT);
/* Sets one pin mask */
GPIO_maskHighSet (hGpio,GPIO_PIN4);
GPIO_maskHighSet (hGpio,GPIO_PIN5);

GPIO_intPolarity( hGpio, GPIO_GPINT4,GPIO_RISING); // GPIO_PIN4 and GPIO_PIN5 are the UART interrups.

GPIO_intPolarity( hGpio, GPIO_GPINT5,GPIO_RISING);

IRQ_enable(IRQ_EVT_GPINT4);
IRQ_enable(IRQ_EVT_GPINT5);

Check Out Industry's First Single-Chip, Multi-Format, Real-Time HD Video Transcoding Solution for Commercial & Consumer End Equipment: www.ti.com/dm6467
Hi,

After u have initialized the GPIO pins, u need to enable the directions
of the pins as below using CSL

GPIO_pinEnable( myGPIO_handle , GPIO_PIN0 );

GPIO_pinDirection(myGPIO_handle , GPIO_PIN0, GPIO_OUTPUT);

Similarly u can configure the other PIN1 as INPUT.

Then u can read the Value of the OUTPUT PIN0 using the CSL API's

#include

Unsigned int Gpio_read_pin0;

Gpio_read_pin0 = GPIO_read( myGPIO_handle , GPIO_PIN0 );

Or u can write a value of 1 or 0 to the PIN( high or low) by using
GPIO_write.

Try this out it has to work.

Regards

Thiyana

________________________________

From: maryam shabro [mailto:m...@yahoo.com]
Sent: Sunday, February 24, 2008 11:21 AM
To: Maitriya, Thiyana (IE10)
Subject: RE: [c6x] gpio init

Hi, Dear Thyia,

So many thanks for your kind support.

i use a DSK c6713 board and I made a project for initializing the GPIO
pins ,as you described before.

(GPIO_pin0 as output and GPIO1 as input)

but it doesnt work.

the above mentioned project files can be find as attachment.

It will be highly appreciated if you guide me for solving this problem.

Thanks

Maryam

"Maitriya, Thiyana (IE10)" wrote:

Hi,

I have provided u below a sample code from TI for C6000
application to configure the GPIO pins, u can modify for ur program.

/* Global Declaration */

GPIO_Handle myGPIO_handle; /* GPIO handle */

Then u need configure the GPIO pins

GPIO_Config MyConfig = { 0x00000000, /* gpgc */

0x00000000, /* gpen --

0x00000000, /* gdir -

0x00000000, /* gpval */

0x00000000, /* gphm all interrupts disabled for io pins */

0x00000000, /* gplm all interrupts to cpu or edma disabled */

0x00000000 /* gppol -- default state */

};

myGPIO_handle = GPIO_open( GPIO_DEV0, GPIO_OPEN_RESET );

GPIO_config(myGPIO_handle , &MyConfig );

Try this out

Regards

Thiya

________________________________
From: c... [mailto:c...] On Behalf
Of m...@yahoo.com
Sent: Wednesday, February 20, 2008 12:32 PM
To: c...
Subject: [c6x] gpio init

Hi all,
I am working with MATLAB/Simlink Embedded Target for C6000 to
try and
prgoram my C6713 DSP but would like to know how to program my
GPIO
pins? please give me some basics to point me in the right
direction.
Thanks
Maryam

Check Out Industry's First Single-Chip, Multi-Format, Real-Time HD Video Transcoding Solution for Commercial & Consumer End Equipment: www.ti.com/dm6467