0% found this document useful (0 votes)
35 views

Chapter

This program writes code for a TMS320F28027 microcontroller to blink LEDs by toggling GPIO pins 0, 1, 2, and 3. It includes the necessary header files, sets the GPIO pins as outputs after selecting them as general purpose pins, and uses an infinite while loop to toggle each pin on and off with a delay, causing the LEDs to blink.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Chapter

This program writes code for a TMS320F28027 microcontroller to blink LEDs by toggling GPIO pins 0, 1, 2, and 3. It includes the necessary header files, sets the GPIO pins as outputs after selecting them as general purpose pins, and uses an infinite while loop to toggle each pin on and off with a delay, causing the LEDs to blink.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Chapter 1

Write A Program of C2000(TMS320F28027) Launchpad Evaluation Kit to GPIO


toggling on GPIO port 0,1,2 and 3 to blink LED.
#include "DSP28x_Project.h"
void main()
{
EALLOW;
SysCtrlRegs.WDCR = 0x0068;
GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 0;
GpioCtrlRegs.GPADIR.bit.GPIO0 = 1;
GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 0;
GpioCtrlRegs.GPADIR.bit.GPIO1 = 1;
GpioCtrlRegs.GPAMUX1.bit.GPIO2 = 0;
GpioCtrlRegs.GPADIR.bit.GPIO2 = 1;
GpioCtrlRegs.GPAMUX1.bit.GPIO3 = 0;
GpioCtrlRegs.GPADIR.bit.GPIO3 = 1;
EDIS;
GpioDataRegs.GPASET.bit.GPIO0 =1;
GpioDataRegs.GPASET.bit.GPIO1 =1;
GpioDataRegs.GPASET.bit.GPIO2 =1;
GpioDataRegs.GPASET.bit.GPIO3 =1;
while(1)
{
GpioDataRegs.GPATOGGLE.bit.GPIO0
DELAY_US(1000000);
GpioDataRegs.GPATOGGLE.bit.GPIO1
DELAY_US(1000000);
GpioDataRegs.GPATOGGLE.bit.GPIO2
DELAY_US(1000000);
GpioDataRegs.GPATOGGLE.bit.GPIO3
DELAY_US(1000000);
}
}

//
//
//
//
//
//
//
//

0=GPIO, 1=EPWM2A,
1=OUTput, 0=INput
0=GPIO, 1=EPWM2A,
1=OUTput, 0=INput
0=GPIO, 1=EPWM2A,
1=OUTput, 0=INput
0=GPIO, 1=EPWM2A,
1=OUTput, 0=INput

2=Resv,

3=Resv

2=Resv,

3=Resv

2=Resv,

3=Resv

2=Resv,

3=Resv

= 1;
= 1;
= 1;
= 1;

GUIDE :

Now here first we have included DSP28x_Project.h Click on it Press F3 to see files Which
includes in it are F2802x_Device.h and f2802x_examples.h..

Again you can open declaration by using F3 on f2802x_examples.h.


In this we can see declaration of PLL clock value and divide select value.

#define DSP28_DIVSEL 2 // Enable /2 for SYSCLKOUT


For DIVSEL 0 and 1 SYSCLKOUT is /4 for DIVSEL 2 is /2 and for DIVSEL 3 is /1.

#define DSP28_PLLCR 12
// for 60 MHz devices [60 MHz = (10MHz * 12)/2]

CPU_RATE can be derived by 1/(CPU_Freq x 10^-9) L

In declaration of main()
Here the register which we are going to access are EALLOW Protected, so for getting access we
have to give EALLOW at beginning.

Here we have to disable watchdog, so it may not run at debug time.

Here we have SysCtrlRegs.WDCR = 0x0068;


Which indicate bit 3,5 and 6 are high. Means WDCHK =101 it must ALWAYS write 1,0,1 to these
bits whenever a write to this register is performed unless the intent is to reset the device via
software.
Then WDDIS= 1 indicate watch dog Disable.

Now We have to Access GPIO for it first we have to access GpioCtrlRegs in which select
GPAMUX1 and set GPIO 0 and 2 as general purpose GPIO.

Then we have to give direction as Output to get LED Blink on that port
GpioCtrlRegs.GPADIR.bit.GPIO0 = 1; By using this we have given direction as output.
The use infinite while Loop for LED blink on GPIO port 0 and 2.
Here we have set toggle bit as 1 of GPIO 2 then some delay then set toggle bit as 1 of GPIO 0
then delay.

NOTE :
Delay_US function will not perform if we have not disable the watchdog.
Here We have to initialize all GPIO and turn it off by GpioDataRegs.GPASET.bit.GPIO0
=1; at starting so it we not blink during the run.

You might also like