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.

TMS320F28335 Port C operations

Other Parts Discussed in Thread: TMS320F28335, CONTROLSUITE

Hello,

I have my custom built hardware for TMS320F28335. I have run some example code of Port toggling. I successfully tested the Port A and B but the Port C is not getting toggled. The code is given below.

#include "DSP2833x_Device.h"
#include "DSP2833x_Examples.h"
//#include "DSP2833x_Gpio.h"

void delay_loop(void);
void LCDport_init(void);

void main (void)
{
	InitSysCtrl();

	DINT;
	InitPieCtrl();
	IER = 0x0000;
	IFR = 0x0000;

	LCDport_init();
//return 0;

}

void delay_loop()
{
    long i;
    for (i = 0; i < 1000000; i++) {}
}

void LCDport_init()
{
	// Set LCD Data pins (D0-D7), LCD R/S pin (D10), LCD R/W pin (D11) and LCD E pin(D12)
	//GpioCtrlRegs.GPCDIR.all = 0x00001CFF;   //
	EALLOW;
	GpioCtrlRegs.GPCMUX2.all = 0x00000000;  // All GPIO
        GpioCtrlRegs.GPCMUX1.all = 0x00000000;  // All GPIO
	GpioCtrlRegs.GPCDIR.all = 0xFFFFFFFF;   //
	EDIS;
	for(;;)
   {

       GpioDataRegs.GPCSET.all = 0xFFFFFFFF;
       //GpioDataRegs.GPCCLEAR.all = 0x55555555;

       delay_loop();

       GpioDataRegs.GPCCLEAR.all = 0xFFFFFFFF;
       //GpioDataRegs.GPCSET.all   = 0x55555555;
       
       delay_loop();

    }
	

}

Please help

Thanks in advance.

  • Neeraj,

    I don't see anything obviously wrong in the code.  Can you try the following?

    1. Make sure the compiler optimizer is disabled in case it's optimizing out the delay loop.  You can check for this be setting break points on both instances of "delay_loop()" and running between them.  If the pins toggle, its likely to be the delay loop timing.

    2. Is anything connected to the port C pins which could be affecting your measurements?  The code comments imply there is an LCD attached to them.  Can you try physically disconnecting those pins to see is it makes a difference?

    Regards,

    Richard

  • Richard,
    Thanks for your reply.


    1. Can you please tell me where compiler optimizer setting is? I looked into the project properties as well as in Help but I couldn't find it.

    2. The port C will be used for LCD but the pins aren't connected to the display. I am checking the port pin status on a DSO.

    Regards,

    Neeraj
  • Neeraj,

    If you are using CCS v6, go to the Edit perspective, then right-click on the project name and select "Properties". You can find the optimization level setting in the tree: Build -> C2000 compiler -> Optimization.  

    Regards,

    Richard

  • Richard,
    Thanks. The compiler optimizer setting is already disabled in the project. I made a new project in a new workspace, but it is still not working. Can you tell me any other way to do it?

    Regards

    Neeraj
  • Neeraj,

    Can you elaborate on "not working" please?  I pasted you code directly into the F28335 CPU timer example in controlSUITE and I can see all active bits in the GPCDAT register toggle as I step through the code.  Do you also see that in your program, or are you saying the GPCDAT register changes but the pin voltages don't?

    Regards,

    Richard

  • Richard,
    Yes. The value in the GPCDAT register changes but the pin voltage remains high.

    Thanks & regards,

    Neeraj
  • Neeraj,

    Thanks.  I have added the code in your post the CPU timer example in controlSUITE and am measuring at four port C GPIO pins on an experimenter kit.  There is nothing between the device I/O pins and the headers where I'm measuring.

    I see the pin voltages clearly changing as I step between the GPCSET and GPCCLEAR lines in your code.  I have attached the modified C file from that example.  If you want to try it, replace the corresponding source file in controlSUITE at:

    C:\ti\controlSUITE\device_support\f2833x\v141\DSP2833x_examples_ccsv5\cpu_timer

    To be sure, just double-check there is nothing else in your code which could be re-configuring any of the port C pins.  If not, I strongly suspect the problem is on your board.  Were you able to physically disconnect the I/O pins to make your measurement?

    Regards,

    Richard

    Example_2833xCpuTimer.c
    //###########################################################################
    // Description
    //! \addtogroup f2833x_example_list
    //! <h1>Cpu Timer (cpu_timer)</h1>
    //!
    //! This example configures CPU Timer0, 1, and 2 and increments
    //! a counter each time the timers asserts an interrupt.
    //!
    //! \b Watch \b Variables \n
    //! - CputTimer0.InterruptCount
    //! - CpuTimer1.InterruptCount
    //! - CpuTimer2.InterruptCount
    //
    //###########################################################################
    // $TI Release: F2833x/F2823x Header Files and Peripheral Examples V141 $
    // $Release Date: November  6, 2015 $
    // $Copyright: Copyright (C) 2007-2015 Texas Instruments Incorporated -
    //             http://www.ti.com/ ALL RIGHTS RESERVED $
    //###########################################################################
    
    #include "DSP28x_Project.h"     // Device Headerfile and Examples Include File
    
    // Prototype statements for functions found within this file.
    __interrupt void cpu_timer0_isr(void);
    __interrupt void cpu_timer1_isr(void);
    __interrupt void cpu_timer2_isr(void);
    
    void delay_loop();
    void LCDport_init();
    
    
    void main(void)
    {
    // Step 1. Initialize System Control:
    // PLL, WatchDog, enable Peripheral Clocks
    // This example function is found in the DSP2833x_SysCtrl.c file.
       InitSysCtrl();
    
    // Step 2. Initialize GPIO:
    // This example function is found in the DSP2833x_Gpio.c file and
    // illustrates how to set the GPIO to it's default state.
    // InitGpio();  // Skipped for this example
    
    // Step 3. Clear all interrupts and initialize PIE vector table:
    // Disable CPU interrupts
       DINT;
    
    // Initialize the PIE control registers to their default state.
    // The default state is all PIE interrupts disabled and flags
    // are cleared.
    // This function is found in the DSP2833x_PieCtrl.c file.
       InitPieCtrl();
    
    // Disable CPU interrupts and clear all CPU interrupt flags:
       IER = 0x0000;
       IFR = 0x0000;
    
    // Initialize the PIE vector table with pointers to the shell Interrupt
    // Service Routines (ISR).
    // This will populate the entire table, even if the interrupt
    // is not used in this example.  This is useful for debug purposes.
    // The shell ISR routines are found in DSP2833x_DefaultIsr.c.
    // This function is found in DSP2833x_PieVect.c.
       InitPieVectTable();
    
    // Interrupts that are used in this example are re-mapped to
    // ISR functions found within this file.
       EALLOW;  // This is needed to write to EALLOW protected registers
       PieVectTable.TINT0 = &cpu_timer0_isr;
       PieVectTable.XINT13 = &cpu_timer1_isr;
       PieVectTable.TINT2 = &cpu_timer2_isr;
       EDIS;    // This is needed to disable write to EALLOW protected registers
    
    // Step 4. Initialize the Device Peripheral. This function can be
    //         found in DSP2833x_CpuTimers.c
       InitCpuTimers();   // For this example, only initialize the Cpu Timers
    
    #if (CPU_FRQ_150MHZ)
    // Configure CPU-Timer 0, 1, and 2 to interrupt every second:
    // 150MHz CPU Freq, 1 second Period (in uSeconds)
    
       ConfigCpuTimer(&CpuTimer0, 150, 1000000);
       ConfigCpuTimer(&CpuTimer1, 150, 1000000);
       ConfigCpuTimer(&CpuTimer2, 150, 1000000);
    #endif
    
    #if (CPU_FRQ_100MHZ)
    // Configure CPU-Timer 0, 1, and 2 to interrupt every second:
    // 100MHz CPU Freq, 1 second Period (in uSeconds)
    
       ConfigCpuTimer(&CpuTimer0, 100, 1000000);
       ConfigCpuTimer(&CpuTimer1, 100, 1000000);
       ConfigCpuTimer(&CpuTimer2, 100, 1000000);
    #endif
    // To ensure precise timing, use write-only instructions to write to the entire register. Therefore, if any
    // of the configuration bits are changed in ConfigCpuTimer and InitCpuTimers (in DSP2833x_CpuTimers.h), the
    // below settings must also be updated.
    
       CpuTimer0Regs.TCR.all = 0x4000; // Use write-only instruction to set TSS bit = 0
       CpuTimer1Regs.TCR.all = 0x4000; // Use write-only instruction to set TSS bit = 0
       CpuTimer2Regs.TCR.all = 0x4000; // Use write-only instruction to set TSS bit = 0
    
    
    /*** for debug ***/
    
       LCDport_init();
    
     /*** end debug ***/
    
    
    // Step 5. User specific code, enable interrupts:
    
    // Enable CPU int1 which is connected to CPU-Timer 0, CPU int13
    // which is connected to CPU-Timer 1, and CPU int 14, which is connected
    // to CPU-Timer 2:
       IER |= M_INT1;
       IER |= M_INT13;
       IER |= M_INT14;
    
    // Enable TINT0 in the PIE: Group 1 interrupt 7
       PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
    
    // Enable global Interrupts and higher priority real-time debug events:
       EINT;   // Enable Global interrupt INTM
       ERTM;   // Enable Global realtime interrupt DBGM
    
    // Step 6. IDLE loop. Just sit and loop forever (optional):
       for(;;);
    }
    
    __interrupt void cpu_timer0_isr(void)
    {
       CpuTimer0.InterruptCount++;
    
       // Acknowledge this interrupt to receive more interrupts from group 1
       PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
    }
    
    __interrupt void cpu_timer1_isr(void)
    {
       CpuTimer1.InterruptCount++;
       // The CPU acknowledges the interrupt.
       EDIS;
    }
    
    __interrupt void cpu_timer2_isr(void)
    {  EALLOW;
       CpuTimer2.InterruptCount++;
       // The CPU acknowledges the interrupt.
       EDIS;
    }
    
    /*** debug below this line ***/
    
    void delay_loop()
    {
        long i;
        for (i = 0; i < 1000000; i++) {}
    }
    
    
    void LCDport_init()
    {
    	int x = 54;;
    
        // Set LCD Data pins (D0-D7), LCD R/S pin (D10), LCD R/W pin (D11) and LCD E pin(D12)
        //GpioCtrlRegs.GPCDIR.all = 0x00001CFF;   //
        EALLOW;
        GpioCtrlRegs.GPCMUX2.all = 0x00000000;  // All GPIO
            GpioCtrlRegs.GPCMUX1.all = 0x00000000;  // All GPIO
        GpioCtrlRegs.GPCDIR.all = 0xFFFFFFFF;   //
        EDIS;
        for(;;)
       {
    
           GpioDataRegs.GPCSET.all = 0xFFFFFFFF;
           //GpioDataRegs.GPCCLEAR.all = 0x55555555;
    
           delay_loop();
    
           GpioDataRegs.GPCCLEAR.all = 0xFFFFFFFF;
           //GpioDataRegs.GPCSET.all   = 0x55555555;
    
           delay_loop();
    
        }
    
    
    }
    
    
    //===========================================================================
    // No more.
    //===========================================================================
    

  • Richard,
    Sorry. I am answering to your help late. Thanks for providing the code. It worked. I didn't physically disconnect any pin but I was able to observe the port toggling over the scope. I rebuilt a new project and it ran very well.

    Heartiest thanks for the help and your patience.
    Warm Regards,

    Neeraj.