You have no items in your shopping cart.

Subtotal: 0.00

How to Interface SWITCH withTMS320F2812 Stick Board

Tms320f2812 Evaluation Board

The Tms320f2812 Evaluation Board is specially desgined for developers in dsp field as well as beginners. The F2812 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 Studio3.1 and later, with XDS100 v1 USB Emulator which is done USB port.

 

Switch

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

 

Interfacing SWITCH with TMS320F2812

The TMS320F2812EVB board has Eight pin Dip SWITCH Connected with Dsp general purpose I/O pins. The pin one side is connected to F2812 port via 2.7kΩ resistor. To read an individual switch , drive the associated port signal to High or Low.

If, the switch is in off condition then the port will read as ‘0’.

If, the switch is in on condition then the port will read as ‘1’.

 

Circuit Diagram to Interface SWITCH with TMS320F2812





In TMS320F2812 KIT., F2812 processor port A is connected to the SWITCH(portA0, portA1,.........portA7).

 

C Program to Read SWITCH using TMS320F2812 KIT

Title : Program to Read SWITCH status and Out To LED.

#include "DSP281x_Device.h" // Prototype statements for functions found within this file. void delay_loop(long); void Gpio_select(void); void InitSystem(void); void main(void) { InitSystem(); // Initialize the DSP's core Registers Gpio_select(); // Setup the GPIO Multiplex Registers while(1) { GpioDataRegs.GPBDAT.all = GpioDataRegs.GPADAT.all; delay_loop(1000000); } } void delay_loop(long end) { long i; for (i = 0; i < end; i++); } void Gpio_select(void) { EALLOW; GpioMuxRegs.GPAMUX.all = 0x0; // all GPIO port Pin's to I/O GpioMuxRegs.GPBMUX.all = 0x0; GpioMuxRegs.GPDMUX.all = 0x0; GpioMuxRegs.GPFMUX.all = 0x0; GpioMuxRegs.GPEMUX.all = 0x0; GpioMuxRegs.GPGMUX.all = 0x0; GpioMuxRegs.GPADIR.all = 0x0; // GPIO PORT as input GpioMuxRegs.GPBDIR.all = 0x00FF; // GPIO Port B15-B8 input , B7-B0 output GpioMuxRegs.GPDDIR.all = 0x0; // GPIO PORT as input GpioMuxRegs.GPEDIR.all = 0x0; // GPIO PORT as input GpioMuxRegs.GPFDIR.all = 0x0; // GPIO PORT as input GpioMuxRegs.GPGDIR.all = 0x0; // GPIO PORT as input GpioMuxRegs.GPAQUAL.all = 0x0; // Set GPIO input qualifier values to zero GpioMuxRegs.GPBQUAL.all = 0x0; GpioMuxRegs.GPDQUAL.all = 0x0; GpioMuxRegs.GPEQUAL.all = 0x0; EDIS; } void InitSystem(void) { EALLOW; SysCtrlRegs.WDCR= 0x0068; // Setup the watchdog // 0x00E8 to disable the Watchdog , Prescaler = 1 // 0x00AF to NOT disable the Watchdog, Prescaler = 64 SysCtrlRegs.SCSR = 0; // Watchdog generates a RESET SysCtrlRegs.PLLCR.bit.DIV = 10; // Setup the Clock PLL to multiply by 5 SysCtrlRegs.HISPCP.all = 0x1; // Setup Highspeed Clock Prescaler to divide by 2 SysCtrlRegs.LOSPCP.all = 0x2; // Setup Lowspeed CLock Prescaler to divide by 4 // Peripheral clock enables set for the selected peripherals. SysCtrlRegs.PCLKCR.bit.EVAENCLK=0; SysCtrlRegs.PCLKCR.bit.EVBENCLK=0; SysCtrlRegs.PCLKCR.bit.SCIAENCLK=0; SysCtrlRegs.PCLKCR.bit.SCIBENCLK=0; SysCtrlRegs.PCLKCR.bit.MCBSPENCLK=0; SysCtrlRegs.PCLKCR.bit.SPIENCLK=0; SysCtrlRegs.PCLKCR.bit.ECANENCLK=0; SysCtrlRegs.PCLKCR.bit.ADCENCLK=0; EDIS; }