Tool/software: Code Composer Studio
I am using the C2000 on the TSM320F28069M, if that's relevant.
I'm trying to use the proper SET and CLEAR registers in my project, so I've gone ahead and configured them as GPIO pins with the following configuration function:
EALLOW; // their directions to outputs GpioDataRegs.GPADAT.all = 0x00000000; GpioDataRegs.GPBDAT.all = 0x00000000; // Define pin functions (as GPIO, I2C, PWM, etc.) GpioCtrlRegs.GPAMUX1.all = 0x00000000; // GPIO0 - GPIO15 GpioCtrlRegs.GPAMUX2.all = 0x05000000; // GPIO16 - GPIO31 GpioCtrlRegs.GPBMUX1.all = 0x00000005; // GPIO32 - GPIO44 GpioCtrlRegs.GPBMUX2.all = 0x00000000; // GPIO50 - GPIO58 GpioCtrlRegs.GPADIR.all = 0x20030000; // Direction of GPIO0 - GPIO31 GpioCtrlRegs.GPBDIR.all = 0x00000087; // Direction of GPIO32 - GPIO44 // Configure the ADC specific pins GpioCtrlRegs.AIOMUX1.all = 0xAAAAAAAA; // Whether the ADC pins are in GPIO or ADC mode GpioCtrlRegs.AIODIR.all = 0x0000FFFE; // What direction each of the ADC pins are // Configure whether the pins are qualified by syncing to the System Clock, or otherwise GpioCtrlRegs.GPAQSEL1.all = 0x00000000; // GPIO0 - GPIO15 GpioCtrlRegs.GPAQSEL2.all = 0x03000000; // GPIO16 - GPIO31 GpioCtrlRegs.GPBQSEL1.all = 0x00000003; // GPIO32 - GPIO44 GpioCtrlRegs.GPBQSEL2.all = 0x00000000; // GPIO45 - GPIO58 // Configure the pull-up (removal of the pins connection) behavior of the pins GpioCtrlRegs.GPAPUD.all = 0x00000000; // GPIO0 - GPIO31 GpioCtrlRegs.GPBPUD.all = 0x00000084; // GPIO32 - GPIO58 EDIS;
And then i assigned them to Macros inside my header file. The relevant ones are as follows:
// Red LED for Debug #define RED_LED_SET GpioDataRegs.GPBSET.bit.GPIO34 #define RED_LED_CLR GpioDataRegs.GPBCLEAR.bit.GPIO34 #define RED_LED GpioDataRegs.GPBDAT.bit.GPIO34 // Step #define STEP_PULSE_SET GpioDataRegs.GPASET.bit.GPIO16 #define STEP_PULSE_CLR GpioDataRegs.GPACLEAR.bit.GPIO16 #define STEP_PULSE GpioDataRegs.GPADAT.bit.GPIO16
Yet, inside my code, whenever I call any of the SET or CLR commands (I even tried Toggle just to be sure) nothing happens. The code I used for that is as follows:
if (LEDDelay >= LED_PRD) { if (toggle) { RED_LED_SET; STEP_PULSE = 1; } else { RED_LED_CLR; STEP_PULSE = 0; } toggle ^= 1; LEDDelay = 0; // Reset the LED timer } else LEDDelay += 1; // Increment by 1 timer2 unit (1000 microseconds)
Using this code, the Red LED does nothing, never changing at all, while the pin (when hooked up to a scope) does change between on and off.
Essentially, I am able to toggle the data register directly, which I know is not-advised, yet I cannot use any of the SET or CLEAR commands. I even tried calling those directly (and not my Macros), inside that loop, to no change. I call InitSysCtrl(); before all of this main looping.