You are currently viewing How to Interface Switch with TMS320C5505

How to Interface Switch with TMS320C5505

Spread the love

The TMS320C5505 DSP Development Board is specially desgined for developers in dsp field as well as beginners. The kit is designed in such way that all the possible features of the DSP will be easily used by the everyone.

The kit supports in Code Composer Studio v4 and later, with XDS100 v1 USB Emulator which is done USB port.

SWITCH

Switches are the most commonly used components, usually to provide the high or low logic to I/O pin’s.

Interfacing SWITCH with TMS320C5505

The TMS320C5505 EVB board has 4 pin DIP switch Connected with Dsp I/O pins. The one end of each switch connects to DSP GPIO pins and another end of each connects to ground via 2.7KΩ resistor. Drive the pins by switch on and off.

Circuit Diagram to Interface SWITCH with TMS320C5505

circuit-diagram-to-interface-switch-with-tms320c5505

C Program to Read SWITCH using TMS320C5505 KIT

#include "stdio.h"
#include "usbstk5515.h"
void TEST_execute( Int16 ( *funchandle )( ), char *testname, Int16 testid )
{
    Int16 status;

    /* Display test ID */
    printf( "%02d  Testing %s...\n", testid, testname );

    /* Call test function */
    status = funchandle( );


    /* Check for test fail */
    if ( status != 0 )
    {
        /* Print error message */
        printf( "     FAIL... error code %d... quitting\n", status );

        /* Software Breakpoint to Code Composer */
        SW_BREAKPOINT;
    }
    else
    {
        /* Print error message */
        printf( "    PASS\n" );
    }
}



extern Int16 switch_test( );
void main( void )
{
    /* Initialize BSL */
    USBSTK5515_init( );
    printf("EXBUSSEL = %02x\n", SYS_EXBUSSEL);
    TEST_execute( switch_test, "Switches", 1 );
    printf( "\n***ALL Tests Passed***\n" );
    SW_BREAKPOINT;
}
#include "usbstk5515.h"
#include "usbstk5515_led.h"
#include "usbstk5515_gpio.h"
#include "sar.h"

Int16 switch_test( )
{

    Uint16 key;
    SYS_EXBUSSEL = 0x4A00;  // Enable LEDs on external bus
    USBSTK5515_SW_init();
    USBSTK5515_ULED_init( );
   
    /* Infinite loop to accept switch inputs */
    while(1)
    {
    	USBSTK5515_SW_getall(&key);
    	if(((key&0x01) == SW1))   // If SW1 pressed
    	{
    		USBSTK5515_ULED_on( 0 );  
    	}
    	else
    	{
    		USBSTK5515_ULED_off( 0 );
    	}

    	if(((key&0x02) == SW2))   // If SW1 pressed
    	{
    		USBSTK5515_ULED_on( 1 );  
    	}
    	else
    	{
    		USBSTK5515_ULED_off( 1 );
    	}
    	if(((key&0x04) == SW3))   // If SW1 pressed
    	{
    		USBSTK5515_ULED_on( 2 );  
    	}
    	else
    	{
    		USBSTK5515_ULED_off( 2 );
    	}


    	if(((key&0x08) == SW4))   // If SW1 pressed
    	{
    		USBSTK5515_ULED_on( 3 );  
    	}
    	else
    	{
    		USBSTK5515_ULED_off( 3 );
    	}    	
     }
    
    return 0;
}

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.