You are on page 1of 3

To mt Project mi cho Concerto f28M36x

bng CCS V6

Hng dn theo ti liu F28M35x_Workshop

Code:

Copy th vin TI vo Foder lm vic


To th mc cha cc Project s thc hin trong tng lai v thm vo
Project hin ti
To Workspace v project mi
To file cu hnh thng tin li vi x l s dng v thit b np
Thm cc file cu hnh v th vin cho project
Startup_ccs: C-runtime support
F28M36xxxx.cmd: physical memory location
Driverlib.lib: source file to initialize
Cu hnh ng dn ti th vin ngun
To hm main vi chng trnh c bn nhy led
Khai bo th vin phn cng
Disable protection and setup clock
Initialize Flash
Disable watchdog
Cp clock cho chn mun iu khin
Cu hnh hng d liu cho chn iu khin l chn ra, khi to
Trng thi ban u
Vo while (1) v vit chng trnh iu khin LED
Bin dch v np

/*
==========================================================================
==============================
TITLE:

Main.c

DESCRIPTION:
Target of this Project is:
Lam quen voi moi truong CCS va nhan M3 cua Concerto F28M36x
1: config code compose for new project
+ Tao project moi
+ Them file cau hinh cho project (.ccxml)
+ Them file cau hinh va thu vien (cau hinh C-runtime, cau hinh bo nho vat ly, thu vien
ma nguon cho cac khoi ngoai vi )
+ Cau hinh trinh bien dich
2: Viet mot project
+ Cau hinh trang thai khoi tao cho nhan M3 cua concerto
+ Chay not ung dung dieu khien ngoai vi - nhay chan GPIO.
Cac chan nhay: Port P pin 0,2,4,6
Port Q Pin 0
RESULT:
ORIGINATOR: ESD Group
Toward the beautiful things :)
--------------------------------------------------------------------------------------------------------Ver | dd mmm yyyy | Who | Description of changes
-----|-------------|------| ----------------------------------------------------------------------------1.00| 29 06 2016 | H.T | The first version
==========================================================================
============================== */
#include "inc/hw_sysctl.h"
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_nvic.h"
#include "inc/hw_types.h"
#include "inc/hw_gpio.h"
#include "driverlib/ipc.h"
#include "driverlib/sysctl.h"
#include "driverlib/interrupt.h"
#include "driverlib/debug.h"
#include "driverlib/cpu.c"
#include "driverlib/gpio.h"
void main (void)
{
volatile unsigned long ulLoop;
// Disable Protection
HWREG(SYSCTL_MWRALLOW) = 0xA5A5A5A5;
// Sets up PLL, M3 running at 75MHz and C28 running at 150MHz
SysCtlClockConfigSet(SYSCTL_USE_PLL | (SYSCTL_SPLLIMULT_M & 0xF) |
SYSCTL_SYSDIV_1 | SYSCTL_M3SSDIV_2 |
SYSCTL_XCLKDIV_4);
// Send boot command to allow the C28 application to begin execution
//IPCMtoCBootControlSystem(CBROM_MTOC_BOOTMODE_BOOT_FROM_FLASH);
//------------------------------- My External Function -----------------#ifdef _FLASH
// Copy time critical code and Flash setup code to RAM
// This includes the following functions: InitFlash();
// The RamfuncsLoadStart, RamfuncsLoadSize, and RamfuncsRunStart
// symbols are created by the linker. Refer to the device .cmd file.
memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);
// Call Flash Initialization to setup flash waitstates

// This function must reside in RAM


FlashInit();
// Send boot command to allow the C28 application to begin execution
IPCMtoCBootControlSystem(CBROM_MTOC_BOOTMODE_BOOT_FROM_FLASH);
#endif
//------------------------------ End of Exteral Function ----------------// Disable clock supply for the watchdog modules
SysCtlPeripheralDisable(SYSCTL_PERIPH_WDOG1);
SysCtlPeripheralDisable(SYSCTL_PERIPH_WDOG0);
// Enable clock supply for GPIOC
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOP);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOQ);
// Set up the Pin for LED3
// Set Direction
GPIOPinTypeGPIOOutput(GPIO_PORTP_BASE, GPIO_PIN_0);
GPIOPinTypeGPIOOutput(GPIO_PORTP_BASE, GPIO_PIN_2);
GPIOPinTypeGPIOOutput(GPIO_PORTP_BASE, GPIO_PIN_4);
GPIOPinTypeGPIOOutput(GPIO_PORTP_BASE, GPIO_PIN_6);
GPIOPinTypeGPIOOutput(GPIO_PORTQ_BASE, GPIO_PIN_0);
// Set Initial state
GPIOPinWrite(GPIO_PORTP_BASE, GPIO_PIN_0, ~0);
GPIOPinWrite(GPIO_PORTP_BASE, GPIO_PIN_2, ~0);
GPIOPinWrite(GPIO_PORTP_BASE, GPIO_PIN_4, ~0);
GPIOPinWrite(GPIO_PORTP_BASE, GPIO_PIN_6, ~0);
GPIOPinWrite(GPIO_PORTQ_BASE, GPIO_PIN_0, ~0);
while (1)
{
// Turn on the LED.
GPIOPinWrite(GPIO_PORTP_BASE, GPIO_PIN_0, 0);
GPIOPinWrite(GPIO_PORTP_BASE, GPIO_PIN_2, 0);
GPIOPinWrite(GPIO_PORTP_BASE, GPIO_PIN_4, 0);
GPIOPinWrite(GPIO_PORTP_BASE, GPIO_PIN_6, 0);
GPIOPinWrite(GPIO_PORTQ_BASE, GPIO_PIN_0, 0);
// Delay for a bit.
for(ulLoop = 0; ulLoop < 2000000; ulLoop++)
{;}
// Turn off the LED.
GPIOPinWrite(GPIO_PORTP_BASE, GPIO_PIN_0, ~0);
GPIOPinWrite(GPIO_PORTP_BASE, GPIO_PIN_2, ~0);
GPIOPinWrite(GPIO_PORTP_BASE, GPIO_PIN_4, ~0);
GPIOPinWrite(GPIO_PORTP_BASE, GPIO_PIN_6, ~0);
GPIOPinWrite(GPIO_PORTQ_BASE, GPIO_PIN_0, ~0);
// Delay for a bit.
for(ulLoop = 0; ulLoop < 2000000; ulLoop++)
{;}
}
}

You might also like