Society of Robots - Robot Forum

Software => Software => Topic started by: orchid on February 04, 2008, 01:51:32 AM

Title: error in compiling
Post by: orchid on February 04, 2008, 01:51:32 AM
hi there,

I am new user of code composer studio software. when I try to compile the source code, this error appear " "main.c", line 63: error: declaration may not appear after executable statement in block ".What is that means?plz somebody help me
Title: Re: error in compiling
Post by: Darkbluestar on February 04, 2008, 03:38:28 AM
If you posted the code it would be much easier to help you. My guess right now would be that you are declaring a variable where you are not suppose to.
Title: Re: error in compiling
Post by: orchid on February 04, 2008, 07:50:33 PM
Actually, I am using the source code provided by the TI website and I just edit it to make it suitable to my application. Do you still want me to upload the source code?
Title: Re: error in compiling
Post by: frank26080115 on February 04, 2008, 10:16:49 PM
Always...

EDIT: Always upload your code so we can actually see what's going on.
Title: Re: error in compiling
Post by: orchid on February 04, 2008, 10:58:29 PM
Hi frank26080115,

what do you means by always? I also get the error such as "  error: symbol referencing errors". What it is and how to fix it?thanx
Title: Re: error in compiling
Post by: airman00 on February 04, 2008, 11:00:13 PM
post your code up

I think I know whats wrong

when you set up symbols for the pins you messed up

upload your code and we'll have a look
Title: Re: error in compiling
Post by: orchid on February 05, 2008, 01:00:48 AM
I am new user of CCS and don't know how to use it. :'(, here I post the source code I do with ADC. Hope you all can give me any idea, if possible, plz give me ur email address of IM so it is easier to me to ask.

#include "DSP281x_Device.h"     // DSP281x Headerfile Include File
#include "DSP281x_Examples.h"   // DSP281x Examples Include File

// Prototype statements for functions found within this file.
interrupt void adc_isr(void);

main()
{

// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP281x_SysCtrl.c file.
   InitSysCtrl();

// For this example, set HSPCLK to SYSCLKOUT / 6 (25Mhz assuming 150Mhz SYSCLKOUT)
   EALLOW;
   SysCtrlRegs.HISPCP.all = 0x3;  // HSPCLK = SYSCLKOUT/6
   EDIS;
   
// Step 2. Initialize GPIO:
// This example function is found in the DSP281x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
// InitGpio();  // Skipped for this example 

// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
   DINT;

// Initialize the 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 DSP281x_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 DSP281x_DefaultIsr.c.
// This function is found in DSP281x_PieVect.c.
   InitPieVectTable();
     
// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.       
   EALLOW;  // This is needed to write to EALLOW protected register
   PieVectTable.ADCINT = &adc_isr;
   EDIS;    // This is needed to disable write to EALLOW protected registers

// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP281x_InitPeripherals.c
// InitPeripherals(); // Not required for this example
   InitAdc();  // For this example, init the ADC

// Step 5. User specific code, enable interrupts:

// Enable ADCINT in PIE
   PieCtrlRegs.PIEIER1.bit.INTx6 = 1;
   IER |= M_INT1; // Enable CPU Interrupt 1
   EINT;          // Enable Global interrupt INTM
   ERTM;          // Enable Global realtime interrupt DBGM

}

#include "DSP281x_Device.h"     // DSP281x Headerfile Include File
#include "DSP281x_Examples.h"   // DSP281x Examples Include File

Uint16 LoopCount;
Uint16 ConversionCount;
Uint16 Voltage1[10];
Uint16 Voltage2[10];


void InitAdc()
{

// Enable ADCINT in PIE
   PieCtrlRegs.PIEIER1.bit.INTx6 = 1;
   IER |= M_INT1; // Enable CPU Interrupt 1
   EINT;          // Enable Global interrupt INTM
   ERTM;          // Enable Global realtime interrupt DBGM

   LoopCount = 0;
   ConversionCount = 0;
   
// Configure ADC
   AdcRegs.ADCMAXCONV.all = 0x0001;       // Setup 2 conv's on SEQ1
   AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x8; // Setup ADCINB0 as 1st SEQ1 conv.
   AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x9; // Setup ADCINB1 as 2nd SEQ1 conv.
   AdcRegs.ADCTRL2.bit.EVA_SOC_SEQ1 = 1;  // Enable EVASOC to start SEQ1
   AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 1;  // Enable SEQ1 interrupt (every EOS)

// Configure EVA
// Assumes EVA Clock is already enabled in InitSysCtrl();
   EvaRegs.T1CMPR = 0x0080;               // Setup T1 compare value
   EvaRegs.T1PR = 0xFFFF;                 // Setup period register
   EvaRegs.GPTCONA.bit.T1TOADC = 1;       // Enable EVASOC in EVA
   EvaRegs.T1CON.all = 0x1042;            // Enable timer 1 compare (upcount mode)

// Wait for ADC interrupt
   while(1)
   {
      LoopCount++;
   }

}


interrupt void  adc_isr(void)
{

  Voltage1[ConversionCount] = AdcRegs.ADCRESULT0 >>4;
  Voltage2[ConversionCount] = AdcRegs.ADCRESULT1 >>4;

  // If 40 conversions have been logged, start over
  if(ConversionCount == 9)
  {
     ConversionCount = 0;
  }
  else ConversionCount++;

  // Reinitialize for next ADC sequence
  AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1;         // Reset SEQ1
  AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1;       // Clear INT SEQ1 bit
  PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;   // Acknowledge interrupt to PIE
 
  return;
}

thanks
Title: Re: error in compiling
Post by: Trumpkin on February 05, 2008, 10:30:28 AM
when you post code click the insert code button above the emoticons and to the right, the button has a # symbol on it.
Title: Re: error in compiling
Post by: orchid on February 05, 2008, 06:19:43 PM
oh ok... i will take note about it next time. tq for your concern :). So, about the source code I posted before, do anyone can help me?

Can you all tell me how to see the output of the source code? When I run the source code such as the example provided by the TI, the result is ok, but how can I see the output?
Title: Re: error in compiling
Post by: Admin on February 17, 2008, 09:24:45 AM
Quote
I am using the source code provided by the TI website and I just edit it to make it suitable to my application. Do you still want me to upload the source code?
The problem is where you edited the code . . . tell us what changes you made.

Oh and when you post code, dont post ALL your code! Post just the code that is relevent to solving the problem (such as where the error occurs).