This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/TMS320F28027F: GPIO Toggle program

Part Number: TMS320F28027F
Other Parts Discussed in Thread: TMDSCNCD28027F, , C2000WARE

Tool/software: Code Composer Studio

Hi,

Can some one help, why the GPIO not toggle with this code ? No error while build/compile. Target also connected. After flash, all four GPIO LEDs stop blinking. 

#include "DSP28x_Project.h" // Device Headerfile and Examples Include File

#include "f2802x_common/include/clk.h"
#include "f2802x_common/include/flash.h"
#include "f2802x_common/include/gpio.h"
#include "f2802x_common/include/pie.h"
#include "f2802x_common/include/pll.h"
#include "f2802x_common/include/wdog.h"

GPIO_Handle myGpio;
CLK_Handle myClk;
void main(void)
{

PLL_Handle myPll;

myClk = CLK_init((void *)CLK_BASE_ADDR, sizeof(CLK_Obj));
myGpio = GPIO_init((void *)GPIO_BASE_ADDR, sizeof(GPIO_Obj));
myPll = PLL_init((void *)PLL_BASE_ADDR, sizeof(PLL_Obj));

CLK_setOscSrc(myClk, CLK_OscSrc_Internal);

PLL_setup(myPll, PLL_Multiplier_10, PLL_DivideSelect_ClkIn_by_2);

myGpio = GPIO_init((void *)GPIO_BASE_ADDR, sizeof(GPIO_Obj));
EALLOW;
((GPIO_Obj *)myGpio)->GPAMUX1 = 0x00000000;
((GPIO_Obj *)myGpio)->GPAMUX2 = 0x00000000;
((GPIO_Obj *)myGpio)->GPBMUX1 = 0x00000000;
((GPIO_Obj *)myGpio)->GPADIR = 0xFFFFFFFF;
((GPIO_Obj *)myGpio)->GPBDIR = 0x0000000F;
EDIS;

for(;;){
GpioDataRegs.GPATOGGLE.bit.GPIO0=1;
GpioDataRegs.GPATOGGLE.bit.GPIO1=1;
GpioDataRegs.GPATOGGLE.bit.GPIO2=1;
GpioDataRegs.GPATOGGLE.bit.GPIO3=1;
DELAY_US(1000000);
}
}

  • Sunil,

    So this code works OK when running from RAM, and not when programmed into flash? Have you setup the device to boot from flash?

    If you are having problems when running from RAM be sure to read the GPIO configuration using the memory browser.

    Regards,
    Cody

  • Hello Mr. Cody, I am very beginner with TI/CCS/C2000. Sorry to ask, how can I setup the device to boot from the flash? Is it with the Switches given on the board S1/S2/S3? I created a linker file from some templates given with ControlSuit. Though I am not using some of the memory sections, I have defined in the linker file. Here it is,

    MEMORY
    {
    PAGE 0: /* Program Memory */
    PRAML0 : origin = 0x008000, length = 0x000800 /* on-chip RAM block L0 */
    OTP : origin = 0x3D7800, length = 0x000400 /* on-chip OTP */
    FLASHD : origin = 0x3F0000, length = 0x002000 /* on-chip FLASH */
    FLASHC : origin = 0x3F2000, length = 0x002000 /* on-chip FLASH */
    FLASHA : origin = 0x3F6000, length = 0x001F80 /* on-chip FLASH */
    CSM_RSVD : origin = 0x3F7F80, length = 0x000076 /* Part of FLASHA. Program with all 0x0000 when CSM is in use. */
    BEGIN : origin = 0x3F7FF6, length = 0x000002 /* Part of FLASHA. Used for "boot to Flash" bootloader mode. */
    CSM_PWL_P0 : origin = 0x3F7FF8, length = 0x000008 /* Part of FLASHA. CSM password locations in FLASHA */

    IQTABLES : origin = 0x3FE000, length = 0x000B50 /* IQ Math Tables in Boot ROM */
    IQTABLES2 : origin = 0x3FEB50, length = 0x00008C /* IQ Math Tables in Boot ROM */
    IQTABLES3 : origin = 0x3FEBDC, length = 0x0000AA /* IQ Math Tables in Boot ROM */

    ROM : origin = 0x3FF27C, length = 0x000D44 /* Boot ROM */
    RESET : origin = 0x3FFFC0, length = 0x000002 /* part of boot ROM */
    VECTORS : origin = 0x3FFFC2, length = 0x00003E /* part of boot ROM */

    PAGE 1 : /* Data Memory */
    BOOT_RSVD : origin = 0x000000, length = 0x000050 /* Part of M0, BOOT rom will use this for stack */
    RAMM0 : origin = 0x000050, length = 0x0003B0 /* on-chip RAM block M0 */
    RAMM1 : origin = 0x000400, length = 0x000400 /* on-chip RAM block M1 */
    DRAML0 : origin = 0x008800, length = 0x000800 /* on-chip RAM block L0 */
    FLASHB : origin = 0x3F4000, length = 0x002000 /* on-chip FLASH */
    }


    SECTIONS
    {

    .cinit : > FLASHA | FLASHC | FLASHD, PAGE = 0
    .pinit : > FLASHA | FLASHC | FLASHD, PAGE = 0
    .text : >> FLASHA | FLASHC | FLASHD, PAGE = 0
    codestart : > BEGIN PAGE = 0
    ramfuncs : LOAD = FLASHA,
    RUN = PRAML0,
    LOAD_START(_RamfuncsLoadStart),
    LOAD_SIZE(_RamfuncsLoadSize),
    RUN_START(_RamfuncsRunStart),
    PAGE = 0

    csmpasswds : > CSM_PWL_P0 PAGE = 0
    csm_rsvd : > CSM_RSVD PAGE = 0

    .stack : > RAMM0 PAGE = 1
    .ebss : > DRAML0 PAGE = 1
    .esysmem : > DRAML0 PAGE = 1
    .sysmem : > DRAML0 PAGE = 1
    .cio : >> RAMM0 | RAMM1 | DRAML0 PAGE = 1
    .econst : > FLASHA PAGE = 0
    .switch : > FLASHA PAGE = 0

    IQmath : > FLASHA PAGE = 0 /* Math Code */
    IQmathTables : > IQTABLES, PAGE = 0, TYPE = NOLOAD

    .reset : > RESET, PAGE = 0, TYPE = DSECT
    vectors : > VECTORS PAGE = 0, TYPE = DSECT
    }

    Thanks and Regards
    Sunil
  • Sunil,

    what EVM are you using? TMDSCNCD28027F?

    If so, you need to configure SW1.

    There is a good guide of how to port a RAM code to FLASH in the one-day Workshop. http://processors.wiki.ti.com/index.php/C2000_Archived_Workshops#F28027_Workshops 

    Regards,
    Cody 

  • Sir, I am using F28027F Launchpad, http://www.ti.com/tool/LAUNCHXL-F28027F

    I am already watching video of one day training C2000. The lab exercise/program work fine but my own program, toggle the GPIO LED, is not working. 

    Thanks

    Sunil

  •  I followed all the step in the Lab 4, www.youtube.com/watch?v=lYcB1O3FpOo 

    Just add this lines to see the GPIO3 toggle. 

    EALLOW;
    GpioCtrlRegs.GPAMUX1.all = 0x00000000; // All GPIO
    GpioCtrlRegs.GPAMUX2.all = 0x00000000; // All GPIO
    GpioCtrlRegs.GPAMUX1.all = 0x00000000; // All GPIO
    GpioCtrlRegs.GPADIR.all = 0xFFFFFFFF; // All outputs
    GpioCtrlRegs.GPBDIR.all = 0x0000000F; // All outputs
    EDIS;

    for(;;) {

    GpioDataRegs.GPATOGGLE.bit.GPIO3=1;

    DELAY_US(1000000);

    }

    Still GPIO3 LED not toggle. Also, Is there any easy way to learn burn/flash Launchpad TMS320F28027F using CCS? There are so many steps mentioned in the video. 

  • Have you verified the contents of the registers using the memory browser?

    What pin are you monitoring on the Launch Pad?

    Many of the examples in C2000Ware are setup to both build in a RAM or a Flash configuration. Simply right click on the the project-> build Configurations -> set active -> Flash.

    Regards,
    Cody
  • This post will be closing soon due to inactivity. feel free to reply back or start a new thread.

    Regards,
    Cody