Jump to content
Sign in to follow this  
BMsoft

Compiler Error C2c Wizard

Recommended Posts

hello everyone,

 

I have the problem with C2C compiler V5.5.1 Project Wizard

 

When I start new project Wizard and I try to compile the program

 

I recive many different error , variable expected , General Error ,

 

Invalid last token, Error in function call and more.

 

The code is generate automatically and I don't have put 1 line of my code,

 

Is this normal ? If no, wich is the solutions ?

 

Can someone help me.

 

many thanks and sorry for my english.

Share this post


Link to post
Share on other sites

Tanks Pavel for help.

 

I try to describe the problem :

 

Start new WinXpProfessional Session

 

Clean , no other program in run.

 

Start SourceBoost Ide 5.5.1

 

-> Select the target Pic16F877

-> Project -> Wizard -> select 16f877

-> Select HS -> 12MHz -> include sleep functions

-> Select project name and directory

C:\programmi\sourceboost\samples\c\moto\moto.__c

 

-> Select use Adc,enable adc interrupt

-> Fosc/32 , left just,ecc...

-> assign ruota_dx to CH0 -> add

-> assign ruota_sx to CH1 -> add

 

-> no compare capture

-> use I2C hw Buffer 0

-> use Rs232 handle Tx,Rx interrupt Buffer 0

-> Boud rate 1200 bps data ends CR

-> Timer 0 WDT 2304

-> Ck internal enable every 10ms

-> Timer 1 external count

-> Timer 2 enable run every 1 ms

 

-> ok and finish

 

Try to compile and riceve Error.

Can you see at the end the file.

 

Many thanks for help.

 

 

/********************************************************************

Filename: moto.c

Created: Sunday, September 05, 2004

Author(s):

History:

 

Purpose:

 

Copyrights© 2004

*********************************************************************/

 

/** \file

\brief Contains main C function and interrupt vector.

 

It contains the application's entry point (main) and the interrupt

vector sector to handle PIC's hardware interrupts. Specific funtions

related to the moto application are contained in

this file as well.

*/

#include <system.h>

#include "moto.h"

#include "piccode.h"

 

#pragma CLOCK_FREQ 12000000

#pragma RS232_BAUD 1200

 

// Define device config block

asm {

list p=16F877

__config H'3FFE' ;UNPROTECT&HS&WDTEN&PWRTDIS&BOREN&LVPEN&DUNPROT&WRTEN&DEBUGDIS

}

 

// Global variables declaration

short i16_Timer0Counter;

short i16_Timer2Counter;

short timer1_clone@0x0E;

char i8_Tasks[TASKS_LIMIT];

char i8_TasksCounter;

char i8_ADCIndex;

char i8_ADCSignal[ADC_SIGNALS];

char i8_ADCChannel[ADC_SIGNALS];

#define RS232_BUFFER_SIZE 0

char b_on_command;

char i8_RS232Index;

char i8_RS232Buffer[RS232_BUFFER_SIZE];

 

/** \defgroup core_functions Application's Core

 

Functions that form the basic structure of the application.

*/

 

/** \brief Executes only once as part of the program boot process.

 

on_init is executed only once when the application has

enter the main loop, usually after boot up initialization.

This is a good place for hardware initialization code that usually

needs to be executed only at the beginning of the program. It contains

PIC's hardware initialization but user can also add any other type of

initializations here.

on_init will be called by the task scheduler.

\sa on_timerx(), on_command(), on_idle()

\ingroup core_functions

*/

void on_init( void )

{

//TODO: add your initialization code

option_reg = 0xDF;

i8_TasksCounter = 0;

// IO ports setup

trisa = 0x3F;

porta = 0x20;

trisb = 0xFF;

portb = 0x00;

trisc = 0xFF;

portc = 0x00;

trisd = 0xFF;

portd = 0x00;

trise = 0x07;

porte = 0x00;

// MSSP setup

sspcon = 0x38;

// ADC setup

adcon0 = 0x81;

adcon1 = 0x00;

adc_init_channels();

// ADC interrupt setup

clear_bit( pir1, ADIF );

set_bit( pie1, ADIE );

// rs232 communications setup

trisc |= 0xC0;

spbrg = 0x9B;

txsta = 0x22;

rcsta = 0x90;

b_on_command = 0;

i8_RS232Index = 0;

// timer 0 setup

tmr0 = 56;

set_bit( intcon, T0IE );

// timer 2 setup

tmr2 = 0;

t2con = 0x00;

set_bit( pie1, TMR2IE );

// enable peripheral and global interrupts

enable_interrupt( PEIE );

enable_interrupt( GIE );

}

 

void on_adc( void )

{

//TODO: This is the default implementation,

// if necessary add code to handle ADC interrupt.

i8_ADCSignal[i8_ADCIndex] = adc_get_adres();

adc_continue();

}

/** \brief Runs user's code when a TX interrupt happened.

 

on_tx executes user's code when a the pic has sent a char.

on_tx will be called by the task scheduler or the user can

call it from the interrupt handler to give it more priority.

\sa on_idle(), on_command(), on_init()

\ingroup core_functions

*/

void on_tx( void )

{

//TODO: add your code here to handle the TX interrupt

}

 

/** \brief Runs user's code when a timer0 timeout has elapsed.

 

on_timer executes user's code when a predefined timer0 timeout has

elapsed. This is a good place for code that needs to be run at

certain time intervals.

on_timer will be called by the task scheduler.

\sa on_idle(), on_command(), on_init()

\ingroup core_functions

*/

void on_timer0( void )

{

//TODO: add your timer 0 code here

}

/** \brief Runs user's code when a timer2 timeout has elapsed.

 

on_timer executes user's code when a predefined timer2 timeout has

elapsed. This is a good place for code that needs to be run at

certain time intervals.

on_timer will be called by the task scheduler.

\sa on_idle(), on_command(), on_init()

\ingroup core_functions

*/

void on_timer2( void )

{

//TODO: add your timer 2 code here

}

/** \brief Runs user's code when there is no other task to run.

 

on_idle is executed continously when there are no other tasks

that need to be executed. Usually this is a good place to put

code that has the lowest priority. on_idle will be called by

the task scheduler. By default, it clears the watchdog timer

to avoid micro reset itself.

\sa on_timerx(), on_command(), on_init()

\ingroup core_functions

*/

void on_idle( void )

{

//TODO: add your idle code here

clear_wdt();

}

 

/** \brief This function is placed at the interrupt vector.

 

interrupt is executed whenever a PIC's hardware interrupt has

been triggered. The user can change, add, or remove the

code in this function to fit the application's needs.

interrupt is automatically called by the PIC's hardware.

\sa main(), on_init()

\ingroup core_functions

*/

void interrupt( void )

{

// TODO: handle interrupts by adding code here

// TODO: move code to fit your apps priorities

// timer 0 interrupt

if ( intcon&0x20 && intcon&0x04 )

{

tmr0 = 56;

clear_bit( intcon, T0IF );

if ( ++i16_Timer0Counter >= 150 )

{

i16_Timer0Counter = 0;

if ( i8_TasksCounter < TASKS_LIMIT )

i8_Tasks[i8_TasksCounter++] = TASK_TIMER0;

}

}

// timer 2 interrupt

if ( pie1&0x02 && pir1&0x02 )

{

tmr2 = 0;

clear_bit( pir1, TMR2IF );

if ( ++i16_Timer2Counter >= 1 )

{

i16_Timer2Counter = 0;

if ( i8_TasksCounter < TASKS_LIMIT )

i8_Tasks[i8_TasksCounter++] = TASK_TIMER2;

}

}

// ADC's measurement is ready

if ( pie1&0x40 && pir1&0x40 )

{

clear_bit( pir1, ADIF );

if ( i8_TasksCounter < TASKS_LIMIT )

i8_Tasks[i8_TasksCounter++] = TASK_ADC;

}

// TXREG has been sent out

if ( pie1&0x10 && pir1&0x10 )

{

clear_bit( pie1, TXIE );

if ( i8_TasksCounter < TASKS_LIMIT )

i8_Tasks[i8_TasksCounter++] = TASK_INT_TX;

}

}

 

/** \brief This is the entry point function for C programs.

 

main is executed (by a goto instruction) after some required

initialization has been executed. The PICC's compiler adds this

initialization code to every C program.

\sa interrupt(), on_init()

\ingroup core_functions

*/

main()

{

// initialize peripherals and the application

on_init();

for (;;)

{

// TODO: this is a very simple tasks scheduler

// replace if your program should become complex

while ( i8_TasksCounter )

{

switch( i8_Tasks[--i8_TasksCounter] )

{

case TASK_TIMER0:

on_timer0();

break;

case TASK_TIMER2:

on_timer2();

break;

case TASK_ADC:

on_adc();

break;

case TASK_INT_TX:

on_tx();

break;

default:

}

}

on_idle();

}

}

 

#ifndef _moto_H_

#define _moto_H_

 

/*

TODO: add declarations in this file that

are specific to your application..

*/

 

#define OSC_FREQUENCY 12000000

 

#define TASKS_LIMIT 8

#define TASK_TIMER0 0

#define TASK_TIMER1 1

#define TASK_TIMER2 2

#define TASK_INT_EXT 3

#define TASK_ADC 4

#define TASK_COMMAND 5

#define TASK_INT_PORTB 6

#define TASK_INT_CCP1 7

#define TASK_INT_CCP2 8

#define TASK_INT_TX 9

 

#define ADC_AUTO 255

#define ADC_SIGNALS 2

#define ADC_CH0_ruota_dx 0

#define ADC_CH0_ruota_sx 1

extern char i8_ADCIndex;

extern char i8_ADCSignal[ADC_SIGNALS];

extern char i8_ADCChannel[ADC_SIGNALS];

 

extern void on_init( void );

 

#endif //_moto_H_

 

/********************************************************************

Filename: piccode.c

Created: Sunday, September 05, 2004

Author(s):

History:

 

Purpose:

 

Copyrights© 2004

*********************************************************************/

 

#include <system.h>

#include "moto.h"

#include "piccode.h"

 

short ccpr1_clone@0x15;

short ccpr2_clone@0x16;

char* pi8_EEData;

 

/** \defgroup sleep_functions Power Saving Support

 

Basic support functions to use microcontroller sleep mode

for power saving applications.

*/

 

/** \brief Executes code before the PIC goes into sleep mode.

 

This function is called by sleep_mode and the user should add

code to setup the PIC's peripherals in order to save the most

power during sleep mode.

\sa on_wake_up(), sleep_mode()

\ingroup sleep_functions

*/

void on_sleep_mode( void )

{

// TODO: add your code to prepare PIC micro

// to go into sleep mode. Setup peripherals to save the

// maximum amount of current in your application

porta = 0xFF;

portb = 0xFF;

portc = 0xFF;

t1con &= 0xFE;

tmr2 &= 0xFB;

}

 

/** \brief Executes code when PIC has waken up.

 

This function is called by sleep_mode function whenever the

PIC has waken up. The user should add code here to determine the

waken-up source, re-initialize the PIC, and/or decide if PIC should

continue in sleep mode.

\return If PIC should continue in sleep mode return 0, return 1 otherwise.

\sa on_sleep_mode(), sleep_mode()

\ingroup sleep_functions

*/

char on_wake_up( void )

{

// TODO: add your code to decide if micro continues

// in sleep mode or fully wakes up.

// If micro should wake up return 1;

on_init();

return 0;

}

 

/** \brief Drives the PIC into sleep mode.

 

This function can be called by the user whenever the PIC should

go into sleep mode. The user should also add code to on_sleep_mode

and on_wake_up to let this function manages the power saving.

\sa on_sleep_mode(), on_wake_up()

\ingroup sleep_functions

*/

void sleep_mode( void )

{

while ( !on_wake_up() )

{

on_sleep_mode();

sleep();

nop();

}

}

 

/** \defgroup eeprom_functions EEPROM Support

 

Basic support functions to have read and write access to the internal's

microcontroller Electrical Erasable Programmable Read Only Memory.

*/

 

/** \brief Low level read from internal EEPROM.

 

This function controls the micro EEPROM internal registers to read a byte

from the specified address.

\param addr A byte specifying EEPROM address to read from.

\return The byte read from EEPROM.

\sa EEPROMRead()

\ingroup eeprom_functions

*/

char _EEPROMRead( char addr )

{

eeadr = addr;

set_bit( eecon1, EEPGD );

set_bit( eecon1, RD );

asm movf _eedata, W

}

 

/** \brief Low level write from internal EEPROM.

 

This function controls the micro EEPROM internal registers to write a byte

data to the specified address.

\param addr A byte specifying EEPROM address to write data to.

\param data The byte to write to addr.

\return Nothing.

\sa EEPROMWrite()

\ingroup eeprom_functions

*/

void _EEPROMWrite( char addr, char data )

{

eeadr = addr;

eedata = data;

 

set_bit( STATUS, RP0 );

set_bit( eecon1, EEPGD );

set_bit( eecon1, WREN );

disable_interrupt( GIE );

eecon2 = 0x55;

eecon2 = 0xAA;

set_bit( eecon1, WR );

enable_interrupt( GIE );

while(eecon1&2);

clear_bit( eecon1, WREN );

clear_bit( STATUS, RP0 );

}

 

/** \brief High level read from internal EEPROM.

 

This function is the user interface to read data from the

internal EEPROM.

\param addr A byte specifying the starting address to read from.

\param data A pointer to a buffer to receive read data.

\param size A byte specifying the number of bytes to read.

\return Nothing.

\sa _EEPROMRead()

\ingroup eeprom_functions

*/

void EEPROMRead( char addr, char size )

{

while ( size-- )

{

*pi8_EEData = _EEPROMRead( addr );

addr++;

pi8_EEData++;

}

}

 

/** \brief High level write to internal EEPROM.

 

This function is the user interface to write data to the

internal EEPROM.

\param addr A byte specifying the starting address to write to.

\param data A pointer to a buffer containing the data to write.

\param size A byte specifying the number of bytes to write.

\return Nothing.

\sa _EEPROMWrite()

\ingroup eeprom_functions

*/

void EEPROMWrite( char addr, char size )

{

while ( size-- )

{

_EEPROMWrite( addr, *pi8_EEData );

addr++;

pi8_EEData++;

}

}

/** \defgroup adc_functions ADC Support

 

Basic support functions to control the Analog-to-Digital

Converter that is internal to the microcontroller.

*/

 

/** \brief High level read from ADC (interrupt version).

 

This function is the user interface to read data from the

internal Analog-to-Digital Converter when using ADC interrupts.

\return A 16-bit unsigned integer containing the 10-bit or 8-bit ADC reading.

\sa adc_start(), adc_read().

\ingroup adc_functions

*/

void adc_init_channels( void )

{

i8_ADCChannel[ADC_CH0_ruota_dx] = ADC_CH0;

i8_ADCChannel[ADC_CH0_ruota_sx] = ADC_CH0;

}

 

/** \brief Continues taking ADC readings.

 

This function can be used when using the ADC in interrupt

mode. Once an ADC reading has initiated by using adc_start

and the ADC result read with adc_get_adres, this function

can be called to continue firing AD conversions.

\return The actual index of the ADC buffer. It returns 0

once all the ADC channels have been read.

\sa adc_start(), adc_read().

\ingroup adc_functions

*/

char adc_continue( void )

{

i8_ADCIndex++;

if ( i8_ADCIndex < ADC_SIGNALS )

{

adc_start( ADC_AUTO );

}

else

{

i8_ADCIndex = 0;

}

return i8_ADCIndex;

}

 

/** \brief High level read from ADC (interrupt version).

 

This function is the user interface to read data from the

internal Analog-to-Digital Converter when using ADC interrupts.

\return A 16-bit unsigned integer containing the 10-bit or 8-bit

ADC reading.

\sa adc_start(), adc_read().

\ingroup adc_functions

*/

short adc_get_adres( void )

{

short _adres;

while ( adcon0&GO );

if ( adcon1&0x80 )

{

_adres = adresl;

_adres = _adres>>8;

_adres |= adresh;

}

else

{

// Assumes that by justifying to the left

// an ADC resolution of 8-bit is desired

_adres = adresh;

}

return _adres;

}

 

/** \brief Initiates an ADC sampling and conversion (interrupt version).

 

This function is the user interface to start up an ADC sampling and reading.

It is used for both interrupt and polling methods for handling the ADC.

The difference is that for the polling version the user does not need to

call this function as it's called by the adc_read() function.

\param adc_ch A byte specifying the channel to read.

\return Nothing.

\sa adc_read(), adc_get_adres().

\ingroup adc_functions

*/

void adc_start( char adc_ch )

{

if ( ADC_AUTO == adc_ch )

{

adc_ch = i8_ADCChannel[i8_ADCIndex];

}

adcon0 &= 0xC7;

adcon0 |= adc_ch;

delay_us( 100 );

set_bit( adcon0, GO );

}

 

/** \brief High level read from ADC (polling version).

 

This function is the user interface to read data from the

internal Analog-to-Digital Converter by selecting a channel. Use

this function when ADC does not interrupt PIC when the reading is ready.

\param adc_ch A byte specifying the channel to read.

\return A 16-bit unsigned integer containing the 10-bit or 8-bit

ADC reading.

\sa adc_start(), adc_get_adres().

\ingroup adc_functions

*/

short adc_read( char adc_ch )

{

if ( ADC_AUTO == adc_ch )

{

i8_ADCIndex = 0xFF;

while( adc_continue() )

{

i8_ADCSignal[i8_ADCIndex] = adc_get_adres();

}

}

else

{

adc_start( adc_ch );

}

return adc_get_adres();

}

 

/** \brief Loads TXREG with data.

 

This function can be used to send data using the PIC's AUSART.

\param char to be loaded into TXREG.

*/

void txreg_putch( char c )

{

clear_wdt();

set_bit( pie1, TXIE );

while( !(txsta&0x02) );

txreg = c;

}

 

 

 

#ifndef _PICCODE_H_

#define _PICCODE_H_

 

#include "moto.h"

 

#define ADC_CH0 0x00

#define ADC_CH1 0x08

#define ADC_CH2 0x10

#define ADC_CH3 0x18

#define ADC_CH4 0x20

#define ADC_CH5 0x28

#define ADC_CH6 0x30

#define ADC_CH7 0x38

 

extern char* pi8_EEData;

 

// firmware/software implementation of I2C

// SDA (data) and SCL (clock) bits

#define I2C_BUFFER_SIZE 0

#define I2C_ERROR 0xFF

#define I2C_OUTPUT 0

#define I2C_INPUT 1

 

 

#define I2C_DELAY_1uS() delay_us( 16 )

#define I2C_DELAY_4uS() delay_us( 16 )

#define I2C_DELAY_5uS() delay_us( 16 )

#define I2C_DELAY_10uS() delay_us( 16 )

 

extern char i8_I2CData[i2C_BUFFER_SIZE];

extern char i2c_send_byte( char );

extern char i2c_read_byte( void );

extern char i2c_open( char );

extern void i2c_send_acknowledge( char more );

extern void i2c_stop( void );

extern void txreg_putch( char c );

extern short timer1_clone;

extern char adc_continue( void );

extern void adc_init_channels( void );

extern short adc_read( char adc_ch );

extern void adc_start( char adc_ch );

extern short adc_get_adres( void );

extern char _EEPROMRead( char addr );

extern void EEPROMRead( char addr, char size );

extern void _EEPROMWrite( char addr, char data );

extern void EEPROMWrite( char addr, char size );

extern void sleep_mode( void );

extern void pwm1_dc_setup( short dc );

extern void pwm2_dc_setup( short dc );

 

#endif // _PICCODE_H_

 

 

 

Compiling...

 

C:\PROGRA~1\SOURCE~1\c2c.exe -PPIC16F877 -SRC -ols -md -O2 -Ip16F877.inc -omoto.asm moto.c piccode.c

 

C2C-plus 5.5.1e C-compiler Copyright© 1998-99,2000-2004 by Pavel Baranov

http://www.picant.com/c2c/c.html

support@picant.com

(Extended version)

 

Licensed to: mauro biffo

 

 

moto.c

moto.c(112): Warning: Possible truncation to 8-bit

piccode.c

piccode.c(75): Error: Unexpected unar operation

piccode.c(75): Error: General error

piccode.c(75): Error: Error in function call

piccode.c(81): Error: General error

piccode.c(147): Error: General error

piccode.c(153): Error: General error

piccode.c(168): Error: General error

piccode.c(170): Error: General error

piccode.c(170): Error: Error in function call. The function was declared as '_EEPROMWrite( char , char )'

piccode.c(170): Error: General error

piccode.c(170): Error: General error

piccode.c(170): Error: General error

piccode.c(170): Error: Invalid last token

piccode.c(174): Error: General error

piccode.c(209): Error: General error

piccode.c(211): Error: General error

piccode.c(211): Error: Error in function call. The function was declared as 'adc_start( char )'

piccode.c(213): Error: General error

piccode.c(214): Error: General error

piccode.c(215): Error: Redefinition of 'i8_ADCIndex'

 

Finished.

Failed to locate output file 'moto.asm'

Done

 

Failed

Share this post


Link to post
Share on other sites
piccode.c(75): Error: Unexpected unar operation

 

I've seen this error before. Seems to be a problem with the ! operator having precedence over function calls. Strictly speaking, the "on_wake_up()" function call should have precedence over the ! operator but it doesn't seem to work in this case. You can work around it by enclosing the function call in parentheses.

 

Try changing this:

while ( !on_wake_up() )

...to this:

while ( !(on_wake_up()) )

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...