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.

LAUNCHXL-F280025C: error #41: expected an identifier // GPIO Write and Read

Part Number: LAUNCHXL-F280025C
Other Parts Discussed in Thread: C2000WARE, SYSCONFIG

Hi,

I'm trying to write and read GPIOs in a CCS 11.1.0.00011 but am finding it unnecessarily difficult and error prone. Toggling a GPIO is working fine by copying gpio_ex2_toggle code, but using led_ex1_blinky code to integrate is not, and is now showing up errors for functions in the .h files. My project combines ADC, SPI and GPIO functionality and I've combined example code from C2000WARE for all functions. ADC and SPI work fine together in one project, but when trying to simply read or write a GPIO the project cannot build. The led_ex1_blinky project does function properly though.

I've included all of the directories from all example projects, tried to use a GPIO module on .sysconfig, then tried without a .sysconfig like in the blinky example and tried all configurations I could find on forum posts. 

Here's the code and some screenshots:

//
// Included Files
//
#include "driverlib.h"
#include "device.h"
#include "board.h"
#include "f28x_project.h"

//
// Defines
//
#define RESULTS_BUFFER_SIZE 256 //buffer for storing conversion results
//(size must be multiple of 16)
//
// Globals
//
uint16_t adcAResults[RESULTS_BUFFER_SIZE];
uint16_t resultsIndex;


void main(void)
{

uint16_t sData = 0; // Send data
uint16_t rData = 0; // Receive data
//
// Initialize device clock and peripherals
//
Device_init();

//
// Disable pin locks and enable internal pullups.
//
Device_initGPIO();

//
// Initialize GPIO and configure the GPIO pin as a push-pull output
//
InitGpio();
GPIO_SetupPinMux(LED1, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(LED1, GPIO_OUTPUT, GPIO_PUSHPULL);

//
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();

//
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();

//
// Board Initialization
// - Configure the ADC and power it up
// - Setup the ADC for continuous conversions on channel 0
//
Board_init();

//
// Enables CPU interrupts
//
Interrupt_enableMaster();

// Initialize results buffer
//
for(resultsIndex = 0; resultsIndex < RESULTS_BUFFER_SIZE; resultsIndex++)
{
adcAResults[resultsIndex] = 0;
}
resultsIndex = 0;


//////////////////////
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
//
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;

//
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
InitPieVectTable();

///////////////////
// Enable global Interrupts and higher priority real-time debug events:
//
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM

//
// Take conversions indefinitely in loop
//
do
{

// Transmit data
SPI_writeDataNonBlocking(mySPI0_BASE, sData);

// Block until data is received and then return it
rData = SPI_readDataBlockingNonFIFO(mySPI0_BASE);

if (rData>1000) {
GPIO_WritePin(myGPIOOutput1, 0);
DEVICE_DELAY_US(500);
GPIO_WritePin(myGPIOOutput1, 1);
DEVICE_DELAY_US(500);
}


// Check received data against sent data
if(rData != sData)
{
// Something went wrong. rData doesn't contain expected data.
ESTOP0;
}

sData++;


//
// Enable ADC interrupts
//
ADC_enableInterrupt(myADC0_BASE, ADC_INT_NUMBER1);
ADC_enableInterrupt(myADC0_BASE, ADC_INT_NUMBER2);
ADC_enableInterrupt(myADC0_BASE, ADC_INT_NUMBER3);
ADC_enableInterrupt(myADC0_BASE, ADC_INT_NUMBER4);

//
// Clear all interrupts flags(INT1-4)
//
HWREGH(myADC0_BASE + ADC_O_INTFLGCLR) = 0x000F;

//
// Initialize results index
//
resultsIndex = 0;

//
// Software force start SOC0 to SOC7
//
HWREGH(myADC0_BASE + ADC_O_SOCFRC1) = 0x00FF;

//
// Keep taking samples until the results buffer is full
//
while(resultsIndex < RESULTS_BUFFER_SIZE)
{
//
// Wait for first set of 8 conversions to complete
//
while(false == ADC_getInterruptStatus(myADC0_BASE, ADC_INT_NUMBER3));

//
// Clear the interrupt flag
//
ADC_clearInterruptStatus(myADC0_BASE, ADC_INT_NUMBER3);

//
// Save results for first 8 conversions
//
// Note that during this time, the second 8 conversions have
// already been triggered by EOC6->ADCIN1 and will be actively
// converting while first 8 results are being saved
//
adcAResults[resultsIndex++] = ADC_readResult(ADCARESULT_BASE,
ADC_SOC_NUMBER0);
adcAResults[resultsIndex++] = ADC_readResult(ADCARESULT_BASE,
ADC_SOC_NUMBER1);
adcAResults[resultsIndex++] = ADC_readResult(ADCARESULT_BASE,
ADC_SOC_NUMBER2);
adcAResults[resultsIndex++] = ADC_readResult(ADCARESULT_BASE,
ADC_SOC_NUMBER3);
adcAResults[resultsIndex++] = ADC_readResult(ADCARESULT_BASE,
ADC_SOC_NUMBER4);
adcAResults[resultsIndex++] = ADC_readResult(ADCARESULT_BASE,
ADC_SOC_NUMBER5);
adcAResults[resultsIndex++] = ADC_readResult(ADCARESULT_BASE,
ADC_SOC_NUMBER6);
adcAResults[resultsIndex++] = ADC_readResult(ADCARESULT_BASE,
ADC_SOC_NUMBER7);

//
// Wait for the second set of 8 conversions to complete
//
while(false == ADC_getInterruptStatus(myADC0_BASE, ADC_INT_NUMBER4));

//
// Clear the interrupt flag
//
ADC_clearInterruptStatus(myADC0_BASE, ADC_INT_NUMBER4);

//
// Save results for second 8 conversions
//
// Note that during this time, the first 8 conversions have
// already been triggered by EOC14->ADCIN2 and will be actively
// converting while second 8 results are being saved
//
adcAResults[resultsIndex++] = ADC_readResult(ADCARESULT_BASE,
ADC_SOC_NUMBER8);
adcAResults[resultsIndex++] = ADC_readResult(ADCARESULT_BASE,
ADC_SOC_NUMBER9);
adcAResults[resultsIndex++] = ADC_readResult(ADCARESULT_BASE,
ADC_SOC_NUMBER10);
adcAResults[resultsIndex++] = ADC_readResult(ADCARESULT_BASE,
ADC_SOC_NUMBER11);
adcAResults[resultsIndex++] = ADC_readResult(ADCARESULT_BASE,
ADC_SOC_NUMBER12);
adcAResults[resultsIndex++] = ADC_readResult(ADCARESULT_BASE,
ADC_SOC_NUMBER13);
adcAResults[resultsIndex++] = ADC_readResult(ADCARESULT_BASE,
ADC_SOC_NUMBER14);
adcAResults[resultsIndex++] = ADC_readResult(ADCARESULT_BASE,
ADC_SOC_NUMBER15);
}

//
// Disable all ADCINT flags to stop sampling
//
ADC_disableInterrupt(myADC0_BASE, ADC_INT_NUMBER1);
ADC_disableInterrupt(myADC0_BASE, ADC_INT_NUMBER2);
ADC_disableInterrupt(myADC0_BASE, ADC_INT_NUMBER3);
ADC_disableInterrupt(myADC0_BASE, ADC_INT_NUMBER4);

//
// At this point, adcAResults[] contains a sequence of conversions
// from the selected channel
//

//
// Software breakpoint, hit run again to get updated conversions
//
/*
asm(" ESTOP0");*/
}
while(1); // Loop forever


}

//
// End of file
//

_________________________

ERROR 1:

ERROR 2:

INCLUDE OPTIONS:

SYSCONFIG (first 2 GPIOs were for an earlier test):

Thanks,

- Michael

  • Just found the solution. Seems there's an error in the led_ex1_blinky example

    • GPIO_writePin() and GPIO_readPin() worked instead of GPIO_WritePin() and GPIO_ReadPin()
    • A .syscfg GPIO module created
    • "f28x_project.h" wasn't included
    • None of the initialisations such as InitPieCtrl(); were included

    Recommendation to the C2000WARE developers: create an led_blinky example with GPIOs configured through .syscfg. It'll make things a lot quicker for us beginners.

    - Michael