Other Parts Discussed in Thread: LAUNCHXL-F280049C, C2000WARE
Tool/software:
Hello,
Below are the devices being used:
MCU: F280049CPZS / Launchpad: LaunchXL-F280049C
For context, I am writing software on CCS and am using the TMS, TDI, TDO, TCK jumpers on the LaunchXL-F280049C to connect to my PCB in order to flash the MCU on my own PCB.
I want to get help with include header issues I have been getting. I have two different CCS workspaces, one workspace just includes example led_ex1_blinky, and the other workspace includes led_ex1_blinky and empty_driverlib_project from the C2000 Ware examples.
In the first workspace I am able to build and run my code within the led_ex1_blinky file which toggles 3 LEDs on and off through GPIO pins. The problem arises in my second workspace where I have the exact same code within the led_ex1_blinky file however I get this error: "C:/ti/c2000/C2000Ware_5_03_00_00/device_support/f28004x/common/include/F28x_Project.h", line 47: fatal error #1965: cannot open source file "f28004x_device.h". I have matched the include option paths between both files in the two workspaces and I still get this error. Furthermore, if I paste this code in the empty_driverlib_project file I get the same error that it cannot open source file f28004x_device.h.
Include option for working workspace (led_ex1_blinky)
I copied this exactly to my other workspace and I still get error. This is the error I receive.
Furthermore, the same code in the empty example file.
I'd appreciate it if I could get some help in how to use the F28x_Project.h header. Furthermore, is it best practice to use this header, or should I not use the header and just include things I need individually like #include "driverlib.h" & #include "device.h". I find that the F28 header gives me a lot of trouble.
For reference, here is the code that I am running in all the trials in different files.
#include "F28x_Project.h"
// GPIO definitions for LEDs
#define DEVICE_GPIO_PIN_LED1 0 // GPIO0 (D1)
#define DEVICE_GPIO_PIN_LED2 2 // GPIO2 (D2)
#define DEVICE_GPIO_PIN_LED3 4 // GPIO4 (D3)
// Function prototypes
void delay_ms(unsigned int ms);
void initializeGPIO(void);
void initializeClock(void);
void main(void) {
// Step 1: Initialize clock and GPIOs
initializeClock(); // Use internal oscillator (INTOSC2)
initializeGPIO(); // Set up GPIOs for LEDs
// Step 2: Main loop to blink LEDs
while (1) {
// Turn ON LEDs (active-high logic, 1 = ON)
GPIO_WritePin(DEVICE_GPIO_PIN_LED1, 1);
GPIO_WritePin(DEVICE_GPIO_PIN_LED2, 1);
GPIO_WritePin(DEVICE_GPIO_PIN_LED3, 1);
delay_ms(100); // Adjusted based on your clock factor (100 ms per DELAY_US(100))
// Turn OFF LEDs (active-high logic, 0 = OFF)
GPIO_WritePin(DEVICE_GPIO_PIN_LED1, 0);
GPIO_WritePin(DEVICE_GPIO_PIN_LED2, 0);
GPIO_WritePin(DEVICE_GPIO_PIN_LED3, 0);
delay_ms(100); // Adjusted based on your clock factor (100 ms per DELAY_US(100))
}
}
// Function to initialize the clock (Uses Internal Oscillator)
void initializeClock(void) {
EALLOW;
// Step 1: Select the internal oscillator (INTOSC2, 10 MHz default)
ClkCfgRegs.CLKSRCCTL1.bit.OSCCLKSRCSEL = 0; // Use INTOSC2
// Step 2: Enable the PLL and configure it for 100 MHz system clock
ClkCfgRegs.SYSPLLCTL1.bit.PLLEN = 1; // Enable PLL
ClkCfgRegs.SYSPLLMULT.bit.IMULT = 10; // Multiply 10 MHz by 10 -> 100 MHz
while (ClkCfgRegs.SYSPLLSTS.bit.LOCKS != 1); // Wait for PLL to lock
// Step 3: Set the system clock divider
ClkCfgRegs.SYSCLKDIVSEL.bit.PLLSYSCLKDIV = 0; // No clock divider (100 MHz)
EDIS;
}
// Function to initialize GPIOs
void initializeGPIO(void) {
InitGpio();
EALLOW;
// Configure LEDs (GPIO0, GPIO2, GPIO4)
GPIO_SetupPinMux(DEVICE_GPIO_PIN_LED1, GPIO_MUX_CPU1, 0); // GPIO0
GPIO_SetupPinMux(DEVICE_GPIO_PIN_LED2, GPIO_MUX_CPU1, 0); // GPIO2
GPIO_SetupPinMux(DEVICE_GPIO_PIN_LED3, GPIO_MUX_CPU1, 0); // GPIO4
GPIO_SetupPinOptions(DEVICE_GPIO_PIN_LED1, GPIO_OUTPUT, GPIO_PUSHPULL);
GPIO_SetupPinOptions(DEVICE_GPIO_PIN_LED2, GPIO_OUTPUT, GPIO_PUSHPULL);
GPIO_SetupPinOptions(DEVICE_GPIO_PIN_LED3, GPIO_OUTPUT, GPIO_PUSHPULL);
// Ensure all LEDs are OFF initially
GPIO_WritePin(DEVICE_GPIO_PIN_LED1, 0);
GPIO_WritePin(DEVICE_GPIO_PIN_LED2, 0);
GPIO_WritePin(DEVICE_GPIO_PIN_LED3, 0);
EDIS;
}
// Millisecond delay function (adjusted for clock scaling)
void delay_ms(unsigned int ms) {
unsigned int j;
for (j = 0; j < ms; j++) {
DELAY_US(100); // 100 microseconds delay (adjusted for clock factor)
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////
Finally, here is what the beginning of my code looks like when I get no issues. Anytime I don't use the F28 header.
#include "driverlib.h"
#include "device.h"
//
// Defines
//
#define SYSCLK 100000000UL // 100 MHz system clock
#define PWM_FREQ 20000UL // 20 kHz
// For UP-count at 20kHz, don't divide by 2:
#define EPWM1_TIMER_TBPRD ((SYSCLK / PWM_FREQ) - 1UL) // = 4999 for 20kHz
// 50% duty cycle
#define EPWM1_DUTY_50 (EPWM1_TIMER_TBPRD / 2UL)
// 80% duty cycle
#define EPWM1_DUTY_80 ((EPWM1_TIMER_TBPRD * 80UL) / 100UL)
//
// Pin assignments
//
#define GPIO0_EPWM1A_PIN 0
#define GPIO1_EPWM1B_PIN 1
#define GPIO6_INPUT_PIN 6
//
// Function Prototypes
//
void initGPIO0(void); // ePWM1A
void initGPIO1(void); // ePWM1B
void initGPIO6(void); // Input from ESP32
void initEPWM1(void); // Set up ePWM1 for complementary outputs
void setEPWM1DutyCycle(uint16_t dutyValue);
Moving forward, I want to write my code in the empty_driverlib_project file that is provided through C2000Ware. What are the necessary modifications I need to make to this folder to not get errors. Include paths? Linkers? Etc...