Part Number: EK-TM4C123GXL
Other Parts Discussed in Thread: TM4C123GH6PM,
Tool/software: Code Composer Studio
I would appreciate assistance in solving the errors noted below..
This code ran in 2015 when I first wrote it. Unfortunately, I no longer have the development system available. However, I do remember that it was developed on CCS7v(?). I guessed about the compiler and driver library. main.c is included in this post.
**** Build of configuration Debug for project Hanukkah_PWM_Sequencer_v2 ****
"C:\\ti\\ccsv7\\utils\\bin\\gmake" -k -j 8 all -O
'Building file: "../main.c"'
'Invoking: ARM Compiler'
"C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.6.LTS/bin/armcl" -mv4 --code_state=32 -O1 --opt_for_speed=3 --fp_mode=relaxed --include_path="I:/A_Hanukkah_CCS Projects_v2/Hanukkah_PWM_Sequencer_v2" --include_path="C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.6.LTS/include" --include_path="C:/ti/tivaware_c_series_2_1_4_178" -g --diag_warning=225 --diag_wrap=off --display_error_number --preproc_with_compile --preproc_dependency="main.d_raw" "../main.c"
>> Compilation failure
subdir_rules.mk:9: recipe for target 'main.obj' failed
"../main.c", line 141: error #20: identifier "GPIO_PD0_M1PWM0" is undefined
"../main.c", line 181: error #20: identifier "GPIO_PE5_M1PWM3" is undefined
2 errors detected in the compilation of "../main.c".
gmake: *** [main.obj] Error 1
gmake: Target 'all' not remade because of errors.
**** Build Finished ****
Thanks!
/* Project name: MOSFET Power Supply_Sequencer_v2
*
* Written by: Bob Samuel
* Initial release: July 4, 2017 xxx-1 (v1.0)
*
*MCU: TM4C123GH6PM
*LaunchPad: EK-TM4C123GXL
*
*PC: Windows 7 pro, Service pack, 1 fully updated
*PC: CPU: i7-2600 3.4GHZ
*PC: 12GB RAM
*
* Release v2.0
* August 2, 2020
* IDE: CCSv7.4
* Compiler: ti-cgt-arm_16.9.6.LTS
* Peripheral Driver Library: tivaware_c_series_2_1_4_178
* XDCtools: None
* -------------------------------------------------------------------------------------
* Code for Switching power supply
* See Power Supply schematic: N-channel MOSFET with OPTOCOUPLER_06-01-1
* -------------------------------------------------------------------------------------
* Code for Interface Optocoupler sequencer:
* See Interface Schematic: Hanukkah_design_notes-2
* -------------------------------------------------------------------------------------
* Switching power supply code uses PWM Module 1 Generator 0 and Generator 3
* PWM Module 1 Generator 0: M1PWM0, GPIO pin PD0. PWMGenConfigure using PWM_GEN_MODE_DOWN
In count down mode, it will count from a value down to zero,
and then reset to the preset value.
This will produce left-aligned PWM signals
(that is the rising edge of the two PWM signals
produced by the generator will occur at the same time).
* PWM Module 1 Generator 3: M1PWM6, GPIO pin PE5. PWMGenConfigure using PWM_GEN_MODE_UP_DOWN
In count up/down mode, it will count up from zero to the preset value, count back down to zero,
and then repeat the process. This will produce center-aligned PWM signals
(that is, the middle of the high/low period of the PWM
signals produced by the generator will occur at the same time).
* -------------------------------------------------------------------------------------
* SysCtlDelay math:
Subroutine to delay in units of seconds
SYSCLK set to 20 MHz = 1/20,000,000 = 0.00000005 Seconds (50ns) = 3 clock cycles * 50ns = 150ns per clock cycle
1 Second = 1,000,000,000ns / 150ns =~ 6666667 clock cycle: .5 second = 6666667/2 = 3333333: .25 second = 3333333/2 = 1666667: .125 second = 1666667/2 = 833334
* -------------------------------------------------------------------------------------
* Sequence: Blink_on_board_Led_Red_Green_Blue_Sequence
* Sequence: Follower_NE-2_1_to_NE-2_8 then NE-2_8 to NE-2_1_Blinking_Sequence
* -------------------------------------------------------------------------------------
*
*/
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_gpio.h"
#include "driverlib/sysctl.c"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.c"
#include "driverlib/gpio.h"
#include "driverlib/debug.h"
#include "driverlib/pwm.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
unsigned long Delay1 = 3333333; // Number of Clock Cycles-1
unsigned long Delay2 = 1666667; // Number of Clock Cycles-2
unsigned long Delay3 = 3333333; // Number of Clock Cycles-3
unsigned long Delay4 = 1666667; // Number of Clock Cycles-4
//function prototypes
/*
void blink_NE2s(); //NE-2's: Starting at left end #1 > #2 > #3 > #4 > #5 > #6 > #7 > #8 > #9
void blink_RGB_LED(); // blink on-board RGB LED
*/
int main()
{
{
// Set-up System Clock (SYSCLK) and PWM Clock (PWMCLK)
SysCtlClockSet( SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ ); // SYSCLK set to 20 MHz (referred to as "ticks")
// TM4C123x_ROM USER’S GUIDE page 199/348
// TM4C123GH6PM RevE DataSheet, Register 8: Run-Mode Clock Configuration (RCC), offset 0x060
// SYSCTL_OSC_MAIN = OSCSRC (Oscillator Source), MOSC (Main oscillator), page 257 / 1409
// SYSCTL_XTAL_16MHZ = XTAL (Crystal Value), page 256/1409
// SYSCTL_SYSDIV_10 = SYSDIV (System Clock Divisor), page 254/1409
// SYSCTL_USE_PLL = USEPWMDIV (Enable PWM Clock Divisor), page 255/1409
// Set-up PWM Clock (PWMCLK)
SysCtlPWMClockSet( SYSCTL_PWMDIV_64 ); // Sets the PWM clock by dividing the 20.0 MHz (ticks) SYSCLK by 64 = PWM clock 312.5 KHz [312,500 Hz] (PWMCLK)
// TM4C123x_ROM USER’S GUIDE page 217/348
// TM4C123GH6PM RevE DataSheet, Register 8: Run-Mode Clock Configuration (RCC), offset 0x060
// SYSCTL_PWMDIV_64 = PWMDIV, page 255/1409
/*------------------ Enable peripheral ports: GPIOA, GPIOB, GPIOD, GPIOE and GPIOF ---------------------*/
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); // Enable GPIO: Port A
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOA)); //This function determines if a particular peripheral is ready to be accessed.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); // Enable GPIO: Port B
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOB)); //This function determines if a particular peripheral is ready to be accessed.
//
SysCtlPeripheralEnable( SYSCTL_PERIPH_GPIOD ); // Enable GPIO: Port D
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOD)); //This function determines if a particular peripheral is ready to be accessed.
//
SysCtlPeripheralEnable( SYSCTL_PERIPH_GPIOE ); // Enable GPIO: Port E
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOE)); //This function determines if a particular peripheral is ready to be accessed.
//
SysCtlPeripheralEnable( SYSCTL_PERIPH_GPIOF ); // Enable GPIO: Port F
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOD)); //This function determines if a particular peripheral is ready to be accessed.
//
//Sets GPIO pins as OUTPUT
GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 );
GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_4 | GPIO_PIN_5| GPIO_PIN_7 );
GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_0 );
GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);
/*-----Configure PWM module 1, Generator 0, PWM 1 to output a defined frequency and pulse duty cycle on GPIO GPIO Port D, Pin PD0 M1PWM0 */
SysCtlPeripheralEnable( SYSCTL_PERIPH_PWM1 ); // Enable the PWM peripheral PWM module 1
GPIOPinTypePWM( GPIO_PORTD_BASE, GPIO_PIN_0 ); // Configures Port D, Pin 0 for use by the PWM peripheral.
//The program loads but will not run on the TM4C123G_LaunchPad when it is a ROM_ API
// The program loads and runs on the TM4C123G_LaunchPad when it is a 2.1.3.156 Driver Library API
GPIOPinConfigure( GPIO_PD0_M1PWM0 ); // Configures the alternate function of Port D, Pin 0 to PWM output
// TM4C123GH6PM Microcontroller Data Sheet-SPMS376E, 23.4 GPIO Pins and Alternate Functions, p1351
PWMGenConfigure( PWM1_BASE, PWM_GEN_0, PWM_GEN_MODE_DOWN ); // Configures a PWM Module 1, Generator 0. In MODE_DOWN, counts from the PWM generator's Period (load) down to zero,
// and then reset to the preset PWM generator's Period (load) value.
// Tiva C Series TM4C123x ROM USER’S GUIDE, PWM, 15.2.1.5 ROM_PWMGenConfigure, page 157.
// TM4C123GH6PM Microcontroller Data Sheet-SPMS376E, 20.3.2 PWM Timer, p1234 & Figure 20-3. PWM Count-Down Mode, p1235
PWMGenPeriodSet( PWM1_BASE, PWM_GEN_0, 5208 ); // Sets the PWM Generator 0's Period (load) value. This is the frequency of the square wave.
// The Period (load) value is defined as the number of PWM clock ticks between zero pulse signals on the generator block.
// PWMCLK frequency [ticks per second (Hz)] = 62,500 ticks per second
// PWM Period = (1/f) = 0.0000032 Seconds per tick
// Desired frequency [f] = number of Hz
// Desired period = (1/f) = Seconds per period
// Ticks per desired period = Seconds per period / Seconds per tick
// 60 Hz = 5208 ticks
PWMPulseWidthSet( PWM1_BASE, PWM_OUT_0, ( PWMGenPeriodGet(PWM1_BASE, PWM_GEN_0) / 12) ); // Sets the PWM Generator 0 pulse width output by using PWMGenPeriodGet to get the period previously set.
// Set Duty Cycle: In this case PWM generator's period is divided the by 10 to get 10% duty cycle.
PWMOutputState( PWM1_BASE, PWM_OUT_0_BIT, true ); // Enables the output of PWM Module 1, Generator 0
PWMGenEnable( PWM1_BASE, PWM_GEN_0 ); // Enables the timer/counter for a PWM Module 1, Generator 0
GPIOPadConfigSet(GPIO_PORTD_BASE, GPIO_PIN_0, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD); // Enable GPIO Port D Pad and Pins 0 for 8 MA output
/*----- Configure PWM module 1, Generator 1, PWM 1 to output a defined frequency and pulse duty cycle on GPIO Port E, Pin PE5 M1PWM3 --------*/
GPIOPinTypePWM( GPIO_PORTE_BASE, GPIO_PIN_5 ); // Configures Port E, Pin 5 for use by the PWM peripheral
//The program loads but will not run on the TM4C123G_LaunchPad when it is a ROM_ API
// The program loads and runs on the TM4C123G_LaunchPad when it is a 2.1.3.156 Driver Library API
GPIOPinConfigure( GPIO_PE5_M1PWM3 ); // Configures the alternate function of Port E, Pin 5 to PWM Generator 1, output 3
// TM4C123GH6PM Microcontroller Data Sheet-SPMS376E, 23.4 GPIO Pins and Alternate Functions, p1351
PWMGenConfigure( PWM1_BASE, PWM_GEN_1, PWM_GEN_MODE_UP_DOWN ); // Configures a PWM Module 1, Generator 1. In MODE_UP_DOWN, counts from the PWM generator's Period (load) down to zero,
/*In count up/down mode, it will count up from zero to the preset value,
count back down to zero, and then repeat the process.
This will produce center-aligned PWM signals
(that is, the middle of the high/low period of the PWM
signals produced by the generator will occur at the same time).*/
// Tiva C Series TM4C123x ROM USER’S GUIDE, PWM, 15.2.1.5 ROM_PWMGenConfigure, page 157
// TM4C123GH6PM Microcontroller Data Sheet-SPMS376E, 20.3.2 PWM Timer, p1234 & Figure 20-4. PWM Count-Up/Down Mode, p1235
PWMGenPeriodSet( PWM1_BASE, PWM_GEN_1, 5208 ); // Sets the PWM Generator 1's Period (load) value. This is the frequency of the square wave.
// The Period (load) value is defined as the number of PWM clock ticks between zero pulse signals on the generator block.
// PWMCLK frequency [ticks per second (Hz)] = 62,500 ticks per second
// PWM Period = (1/f) = 0.0000032 Seconds per tick
// Desired frequency [f] = number of Hz
// Desired period = (1/f) = Seconds per period
// Ticks per desired period = Seconds per period / Seconds per tick
// 60 Hz = 5208 ticks
PWMPulseWidthSet( PWM1_BASE, PWM_OUT_3, ( PWMGenPeriodGet(PWM1_BASE, PWM_GEN_1) / 12 ) ); // Sets the PWM Generator 1 pulse width output (Duty Cycle) by using PWMGenPeriodGet to get the period previously set.
// In this case PWM generator's period is divided the by 10 to get 10% duty cycle.
PWMOutputState( PWM1_BASE, PWM_OUT_3_BIT, true ); // Enables the output of PWM Module 1, Generator 2, PWM 3
PWMGenEnable( PWM1_BASE, PWM_GEN_1 ); // Enables the timer/counter for a PWM Module 1, Generator 1
GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_5, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD); // Enable GPIO Port F Pad and Pin 0 for 8 MA output
}
/*------------------------------------- Blink_on_board_Led_Red_Green_Blue -------------------------------*/
int a;
for(a=0;a<1;a=a+1)
{
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1, GPIO_PIN_1); // On board tri-color LED - Red
SysCtlDelay(Delay1);
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1, 0);
SysCtlDelay(Delay2);
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_2, GPIO_PIN_2); // On board tri-color LED - Blue
SysCtlDelay(Delay1);
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_2, 0);
SysCtlDelay(Delay2);
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_3, GPIO_PIN_3); // On board tri-color LED - Green
SysCtlDelay(Delay1);
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_3, 0);
SysCtlDelay(Delay2);
}
/*------------------------------------- Follower_NE-2_1_to_NE-2_8 then NE-2_8 to NE-2_1_Blinking_Sequence -------------------------------*/
int b; // variable –32,768 to 32,767 16-bit
for(b=0;b<2000;b=b+1)
{
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_2, GPIO_PIN_2); // Left end NE-2
SysCtlDelay(Delay3);
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_2, 0);
SysCtlDelay(Delay4);
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_3, GPIO_PIN_3);
SysCtlDelay(Delay3);
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_3, 0);
SysCtlDelay(Delay4);
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_4, GPIO_PIN_4);
SysCtlDelay(Delay3);
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_4, 0);
SysCtlDelay(Delay4);
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_5, GPIO_PIN_5);
SysCtlDelay(Delay3);
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_5, 0);
SysCtlDelay(Delay4);
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_6, GPIO_PIN_6); // Center NE-2
SysCtlDelay(Delay3);
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_6, 0);
SysCtlDelay(Delay4);
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_7, GPIO_PIN_7);
SysCtlDelay(Delay3);
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_7, 0);
SysCtlDelay(Delay4);
GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_4, GPIO_PIN_4);
SysCtlDelay(Delay3);
GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_4, 0);
SysCtlDelay(Delay4);
GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_5, GPIO_PIN_5);
SysCtlDelay(Delay3);
GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_5, 0);
SysCtlDelay(Delay4);
GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_7, GPIO_PIN_7); // Right end NE-2
SysCtlDelay(Delay3);
GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_7, 0);
SysCtlDelay(Delay4);
GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_5, GPIO_PIN_5);
SysCtlDelay(Delay3);
GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_5, 0);
SysCtlDelay(Delay4);
GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_4, GPIO_PIN_4);
SysCtlDelay(Delay3);
GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_4, 0);
SysCtlDelay(Delay4);
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_7, GPIO_PIN_7);
SysCtlDelay(Delay3);
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_7, 0);
SysCtlDelay(Delay4);
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_6, GPIO_PIN_6); // Center NE-2
SysCtlDelay(Delay3);
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_6, 0);
SysCtlDelay(Delay4);
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_5, GPIO_PIN_5);
SysCtlDelay(Delay3);
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_5, 0);
SysCtlDelay(Delay4);
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_4, GPIO_PIN_4);
SysCtlDelay(Delay3);
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_4, 0);
SysCtlDelay(Delay4);
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_3, GPIO_PIN_3);
SysCtlDelay(Delay3);
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_3, 0);
SysCtlDelay(Delay4);
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_2, GPIO_PIN_2); // Left end NE-2
SysCtlDelay(Delay3);
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_2, 0);
SysCtlDelay(Delay4);
}
return(0);
}
>> Compilation failure
subdir_rules.mk:9: recipe for target 'main.obj' failed
"../main.c", line 141: error #20: identifier "GPIO_PD0_M1PWM0" is undefined
"../main.c", line 181: error #20: identifier "GPIO_PE5_M1PWM3" is undefined
2 errors detected in the compilation of "../main.c".
gmake: *** [main.obj] Error 1
gmake: Target 'all' not remade because of errors.
**** Build Finished ****
IDE Environment and Configuration:
*MCU: TM4C123GH6PM
*LaunchPad: EK-TM4C123GXL
*
*PC: Windows 7 pro, Service pack, 1 fully updated
*PC: CPU: i7-2600 3.4GHZ
*PC: 12GB RAM
*
* Project release v2.0
* August 2, 2020
* IDE: CCSv7.4
* Compiler: ti-cgt-arm_16.9.6.LTS
* Peripheral Driver Library: tivaware_c_series_2_1_4_178
* XDCtools: None

