Other Parts Discussed in Thread: CONTROLSUITE
Hello Everyone,
I have a TMDSPREX28335 experimental kit with me. It has got 4 LEDs on it and they are connected to the GPIOs as follows:
LED1: GPIO9
LED2: GPIO11
LED3: GPIO34
LED4: GPIO49
In order to understand the kit I used the concept of the Example_2833xGpioToggle.c program and modified it to only toggle the 4 LEDs and the corresponding GPIOs. The code is attached for clarity.
// OBJECTIVE IS TO CONFIGURE GPIOs AS GPIOs
// AND TOGGLE TO OBTAIN A PWM OUTPUT ON OSCILLOSCOPE
// using TOGGLE registers to TOGGLE
// Included Files
//
#include "DSP28x_Project.h" // Device Headerfile and Examples Include File
//
// Defines that select the example to compile in.
// Only one example should be set as 1 the rest should be set as 0.
//
#define EXAMPLE3 1 // Use TOGGLE registers to toggle I/O's
//
// Function Prototypes
//
void delay_loop(void);
void Gpio_example3(void);
//
// Main
//
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
//
// For this example use the following configuration
//
EALLOW;
GpioCtrlRegs.GPAMUX1.all = 0x00000000; // All GPIO
GpioCtrlRegs.GPAMUX2.all = 0x00000000; // All GPIO
GpioCtrlRegs.GPBMUX1.all = 0x00000000; // All GPIO
GpioCtrlRegs.GPBMUX2.all = 0x00000000; // All GPIO
GpioCtrlRegs.GPADIR.all = 0xFFFFFFFF; // All outputs
GpioCtrlRegs.GPBDIR.all = 0xFFFFFFFF; // All outputs
GpioCtrlRegs.GPAQSEL1.all = 0x0000; // GPIO0-GPIO15 Synch to SYSCLKOUT
GpioCtrlRegs.GPAQSEL2.all = 0x0000; // GPIO16-GPIO31 Synch to SYSCLKOUT
GpioCtrlRegs.GPBQSEL1.all = 0x0000; // GPIO32-GPIO39 Synch to SYSCLKOUT
GpioCtrlRegs.GPBQSEL2.all = 0x0000; // GPIO48-GPIO63 Synch to SYSCLKOUT
GpioCtrlRegs.GPAPUD.all = 0xFFFFFFFF; // Pullup's disabled GPIO0-GPIO31
GpioCtrlRegs.GPBPUD.all = 0xFFFFFFFF; // Pullup's disabled GPIO32-GPIO34
EDIS;
//
// Step 3. Clear all interrupts and initialize PIE vector table
// Disable CPU interrupts
//
DINT;
//
// Initialize 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();
//
// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP2833x_InitPeripherals.c
//
// InitPeripherals(); // Not required for this example
//
// Step 5. User specific code:
//
#if EXAMPLE3
//
// This example uses TOGGLE registers to toggle I/O's
//
Gpio_example3();
#endif
}
//
// delay_loop -
//
void delay_loop()
{
volatile long i;
for (i = 0; i < 5000000; i++)
{
asm(" NOP");
EALLOW;
SysCtrlRegs.WDKEY = 0x55;
SysCtrlRegs.WDKEY = 0xAA;
EDIS;
}
}
//
// Gpio_example3 -
//
void Gpio_example3(void)
{
//
// Example 2: Toggle I/Os using TOGGLE registers
//
//
// Set pins to a known state
//
GpioDataRegs.GPADAT.bit.GPIO9 =1;
GpioDataRegs.GPADAT.bit.GPIO11 =0;
GpioDataRegs.GPBDAT.bit.GPIO34 =1;
GpioDataRegs.GPBDAT.bit.GPIO49 =0;
//
// Use TOGGLE registers to flip the state of the pins.
// Any bit set to a 1 will flip state (toggle)
// Any bit set to a 0 will not toggle.
//
for(;;)
{
GpioDataRegs.GPATOGGLE.bit.GPIO9 =1;
GpioDataRegs.GPATOGGLE.bit.GPIO11 =1;
GpioDataRegs.GPBTOGGLE.bit.GPIO34 =1;
GpioDataRegs.GPBTOGGLE.bit.GPIO49 =1;
delay_loop();
}
}
//
// End of File
//
If I modify the code a bit from line 131 to line 134 as per the details in the attached table I see an unexpected sort of a behaviour from the kit. The observations are also included in the table.
| Case 1 | Case 2 | Case 3 | Case 4 | Case 5 | Case 6 | Case 7 | |
| GPIO (LED) | GPxDAT | GPxDAT | GPxSET | GPxSET | GPxSET | GPxCLEAR | GPxCLEAR |
| 9 (1) | 1 | 0 | 0 | 1 | 0 | 1 | 0 |
| 11 (2) | 0 | 1 | 0 | 0 | 1 | 0 | 1 |
| 34 (3) | 1 | 0 | 1 | 1 | 0 | 1 | 0 |
| 49 (4) | 0 | 1 | 1 | 0 | 1 | 0 | 1 |
| Observations | LED1 and LED2 should switch complementary to each other however, they both switch ON and OFF at the same time. LED3 and LED4 are switching complementary to each other. Erratic behaviour |
LED1 and LED2 are glowing alternatively. LED3 and LED4 are glowing alternatively. Normal behaviour |
LED1 and LED2 are not glowing at all. LED3 and LED4 are glowing at the same.
Erratic behaviour |
LED1 and LED2 are glowing alternatively. LED3 and LED4 are glowing alternatively. Normal behaviour |
LED1 and LED2 are glowing alternatively. LED3 and LED4 are glowing alternatively. Normal behaviour |
LED1, LED2, LED3, and LED4 all are switching ON and OFF at the same time. Erratic behaviour |
LED1, LED2, LED3, and LED4 all are switching ON and OFF at the same time. Erratic behaviour |
Can anyone throw some light on why I am encountering such exceptional behaviour in cases 1, 3, 6 and 7?
With Regards,
Ankit
PS: There might be many more possible combinations that I haven't tried which may possibly generate unexpected outputs!!!!!
PPS: A thorough explanation or/and criticism is/are more than welcome

