CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Always my great problem: how to create the project

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
richi-d



Joined: 28 Aug 2007
Posts: 106

View user's profile Send private message

Always my great problem: how to create the project
PostPosted: Wed Mar 12, 2008 6:58 am     Reply with quote

Can anyone tell me how I create a optimal project structure?
Where must be the Header filer and the Subroutines in MPLAB
Where do I have to declare variables
Where is the right place for including the files?
What the right form of the *.h file....

Here is my solution- it doesn´t work:
The error is about 100 times:
*** Error 28 "S:\Abteilung\AnaSys\DICE\Software\Extension_Bedienboard\Display_Steuerung.c" Line 153(36,37): Expecting an identifier
*** Error 43 "S:\Abteilung\AnaSys\DICE\Software\Extension_Bedienboard\Display_Steuerung.c" Line 154(1,2): Expecting a declaration

MAIN.C:
Code:

#include <18F4620.h>
#device adc=10
#include <string.h>
#include "Display_Steuerung.h"

#FUSES HS,NOWDT,NOPROTECT,NOPUT,NOBROWNOUT,NOLVP,NOCPD,NOWRT,DEBUG

#use delay(clock=8000000)


#use STANDARD_IO (A)
#use STANDARD_IO (B)
#use STANDARD_IO (C)
#use STANDARD_IO (D)
#use STANDARD_IO (E)

#define NOP   #asm NOP #endasm;

#define   LE_MUX_1      PIN_C0
#define   LE_MUX_2      PIN_C1
#define   LE_MUX_3      PIN_C2
#define   LE_MUX_4      PIN_D7

#define   CLK            PIN_C3
#define   DATA         PIN_C5

#define   LE_DATA_0      PIN_D0
#define   LE_DATA_1      PIN_D1
#define   LE_DATA_2      PIN_D2
#define   LE_DATA_3      PIN_D3

#define   AUX_LO_UL      PIN_D4
#define   AUX_LO_DL      PIN_D5

#define   PWR_DOWN      PIN_D6

#define   R_S            PIN_E0
#define   R_W            PIN_E1
#define   ENABLE         PIN_E2

#define   OUTPUT_4      PIN_A4
#define   OUTPUT_5      PIN_A5
#define   OUTPUT_6      PIN_A7
#define   OUTPUT_7      PIN_A6

#define GEBER_1_A        PIN_B0 
#define GEBER_1_B        PIN_B4
#define GEBER_2_A        PIN_B1
#define GEBER_2_B       PIN_B5

#define ENTER_1         PIN_B2
#define ENTER_2         PIN_B3


int      ADRESSE;
int      DATA;
int      x_POS;
int      y_POS;
int      THOUS;
int      HUNS;
int      TENS;
int      UNITS;
int      DISPLAY_ZAHLER;

short   SCHALTZUSTAND_1;


int      lenght;


short      STATUS_1_A;
short      STATUS_1_B;
short      STATUS_1_A_ALT;
short      STATUS_2_A;
short      STATUS_2_B;
short      STATUS_2_A_ALT;

short      BESTATIGT;
short      ENTER_RAD_1_BIT;
short      VERSTELLT;
short      SPEICHERN;
short      CONN_MERKER;

int         TYP; 
int         PART;

long      RAD_1;
long      RAD_2;
long      i;
long      x;
long      WERT;











#include "Display_Steuerung.c"

void main()
   {


   Display_Init();



   for (;;)
      {   

      Write_Display_Data ( 0, 1, 'R' );

      }// for()
   } //main()




Display_Steuerung.c :
Code:
void Display_Init (void)
   {
   output_low(ENABLE);
   delay_ms(50);

   output_bit( PIN_C0, 1);      //Function Set
   output_bit( PIN_C1, 1);
   output_bit( PIN_C2, 0);
   output_bit( PIN_C3, 0);
   output_low(R_S);
   output_low(R_W);
   output_high(ENABLE);
   delay_us(5);
   output_low(ENABLE);

   delay_ms(1);

   output_bit( PIN_C0, 1);      //Function Set
   output_bit( PIN_C1, 1);
   output_bit( PIN_C2, 0);
   output_bit( PIN_C3, 0);
   output_low(R_S);
   output_low(R_W);
   output_high(ENABLE);
   delay_us(5);
   output_low(ENABLE);

   delay_ms(1);

   output_bit( PIN_C0, 1);      //Function Set
   output_bit( PIN_C1, 1);
   output_bit( PIN_C2, 0);
   output_bit( PIN_C3, 0);
   output_low(R_S);
   output_low(R_W);
   output_high(ENABLE);
   delay_us(5);
   output_low(ENABLE);

   delay_ms(1);

   output_bit( PIN_C0, 0);      //Function Set 4 BIT
   output_bit( PIN_C1, 1);
   output_bit( PIN_C2, 0);
   output_bit( PIN_C3, 0);
   output_low(R_S);
   output_low(R_W);
   output_high(ENABLE);
   delay_us(5);
   output_low(ENABLE);

   delay_ms(1);

////////////////////////////////////////////////////////////////////////////////////////

   delay_ms(1);
   output_bit( PIN_C0, 0);      //Function Set
   output_bit( PIN_C1, 1);
   output_bit( PIN_C2, 0);
   output_bit( PIN_C3, 0);
   output_low(R_S);
   output_low(R_W);
   output_high(ENABLE);
   delay_us(5);
   output_low(ENABLE);
   output_bit( PIN_C0, 0);      
   output_bit( PIN_C1, 0);
   output_bit( PIN_C2, 0);      //Display OFF
   output_bit( PIN_C3, 1);      //2 Lines
   output_high(ENABLE);
   delay_us(5);
   output_low(ENABLE);

   delay_ms(1);

   output_bit( PIN_C0, 0);      //Display ON/OFF Control
   output_bit( PIN_C1, 0);
   output_bit( PIN_C2, 0);
   output_bit( PIN_C3, 0);
   output_low(R_S);
   output_low(R_W);
   output_high(ENABLE);
   delay_us(10);
   output_low(ENABLE);
   output_bit( PIN_C0, 0);
   output_bit( PIN_C1, 0);      //Blink ON/OFF
   output_bit( PIN_C2, 0);      //Cursor ON/OFF
   output_bit( PIN_C3, 1);      // Display ON/OFF
   output_high(ENABLE);
   delay_us(10);
   output_low(ENABLE);

   delay_ms(1);

   output_bit( PIN_C0, 0);      //Display Clear
   output_bit( PIN_C1, 0);
   output_bit( PIN_C2, 0);
   output_bit( PIN_C3, 0);
   output_low(R_S);
   output_low(R_W);
   output_high(ENABLE);
   delay_us(10);
   output_low(ENABLE);
   output_bit( PIN_C0, 1);
   output_bit( PIN_C1, 0);
   output_bit( PIN_C2, 0);
   output_bit( PIN_C3, 0);
   output_high(ENABLE);
   delay_us(10);
   output_low(ENABLE);

   delay_ms(2);

   output_bit( PIN_C0, 0);      //Entry Mode Set
   output_bit( PIN_C1, 0);
   output_bit( PIN_C2, 0);
   output_bit( PIN_C3, 0);
   output_low(R_S);
   output_low(R_W);
   output_high(ENABLE);
   delay_us(10);
   output_low(ENABLE);
   output_bit( PIN_C0, 0);      //Entire Shift off/on      
   output_bit( PIN_C1, 1);      //Decrement Mode/Increment Mode
   output_bit( PIN_C2, 0);
   output_bit( PIN_C3, 0);
   output_high(ENABLE);
   delay_us(10);
   output_low(ENABLE);

   delay_ms(1);

   output_bit( PIN_C0, 0);      
   output_bit( PIN_C1, 0);
   output_bit( PIN_C2, 0);
   output_bit( PIN_C3, 0);
   output_low(R_S);
   output_low(R_W);
   output_high(ENABLE);
   delay_us(10);
   output_low(ENABLE);
   output_bit( PIN_C0, 0);      
   output_bit( PIN_C1, 0);   
   output_bit( PIN_C2, 1);
   output_bit( PIN_C3, 1);
   output_high(ENABLE);
   delay_us(10);
   output_low(ENABLE);

   delay_ms(1);
   }

void Write_CG_Data ( ADRESSE, DATA )
   {
   delay_ms(1);
   output_bit( PIN_C3, 0);
   output_bit( PIN_C2, 1);
   output_bit( PIN_C1, BIT_TEST(ADRESSE, 5));
   output_bit( PIN_C0, BIT_TEST(ADRESSE, 4));
   output_low(R_S);
   output_low(R_W);
   output_high(ENABLE);
   delay_us(10);
   output_low(ENABLE);
   output_bit( PIN_C0, BIT_TEST(ADRESSE, 0));
   output_bit( PIN_C1, BIT_TEST(ADRESSE, 1));
   output_bit( PIN_C2, BIT_TEST(ADRESSE, 2));
   output_bit( PIN_C3, BIT_TEST(ADRESSE, 3));
   output_high(ENABLE);
   delay_us(10);
   output_low(ENABLE);

   delay_ms(1);
   output_bit( PIN_C0, BIT_TEST(DATA, 4));
   output_bit( PIN_C1, BIT_TEST(DATA, 5));
   output_bit( PIN_C2, BIT_TEST(DATA, 6));
   output_bit( PIN_C3, BIT_TEST(DATA, 7));
   output_high(R_S);
   output_low(R_W);
   output_high(ENABLE);
   delay_us(10);
   output_low(ENABLE);
   output_bit( PIN_C0, BIT_TEST(DATA, 0));
   output_bit( PIN_C1, BIT_TEST(DATA, 1));
   output_bit( PIN_C2, BIT_TEST(DATA, 2));
   output_bit( PIN_C3, BIT_TEST(DATA, 3));


   output_high(ENABLE);
   delay_us(10);
   output_low(ENABLE);
   }



void Write_Display_Data ( x_POS, y_POS, DATA )
   {   
   delay_ms(1);
   if (y_POS == 1)
      {
      output_bit( PIN_C0, 0);
      output_bit( PIN_C1, 0);
      output_bit( PIN_C2, 0);
      output_bit( PIN_C3, 1);
      output_low(R_S);
      output_low(R_W);
      output_high(ENABLE);
      delay_us(10);
      output_low(ENABLE);
      output_bit( PIN_C0, BIT_TEST(x_POS, 0));
      output_bit( PIN_C1, BIT_TEST(x_POS, 1));
      output_bit( PIN_C2, BIT_TEST(x_POS, 2));
      output_bit( PIN_C3, BIT_TEST(x_POS, 3));
      output_high(ENABLE);
      delay_us(10);
      output_low(ENABLE);
      }
   if (y_POS == 2)
      {
      output_bit( PIN_C0, 0);
      output_bit( PIN_C1, 0);
      output_bit( PIN_C2, 1);
      output_bit( PIN_C3, 1);
      output_low(R_S);
      output_low(R_W);
      output_high(ENABLE);
      delay_us(10);
      output_low(ENABLE);
      output_bit( PIN_C0, BIT_TEST(x_POS, 0));
      output_bit( PIN_C1, BIT_TEST(x_POS, 1));
      output_bit( PIN_C2, BIT_TEST(x_POS, 2));
      output_bit( PIN_C3, BIT_TEST(x_POS, 3));
      output_high(ENABLE);
      delay_us(10);
      output_low(ENABLE);
      }

   delay_ms(1);
   output_bit( PIN_C0, BIT_TEST(DATA, 4));
   output_bit( PIN_C1, BIT_TEST(DATA, 5));
   output_bit( PIN_C2, BIT_TEST(DATA, 6));
   output_bit( PIN_C3, BIT_TEST(DATA, 7));
   output_high(R_S);
   output_low(R_W);
   output_high(ENABLE);
   delay_us(10);
   output_low(ENABLE);
   output_bit( PIN_C0, BIT_TEST(DATA, 0));
   output_bit( PIN_C1, BIT_TEST(DATA, 1));
   output_bit( PIN_C2, BIT_TEST(DATA, 2));
   output_bit( PIN_C3, BIT_TEST(DATA, 3));
   output_high(ENABLE);
   delay_us(10);
   output_low(ENABLE);
   }




Display_Steuerung.h :
Code:

void Display_Init ( void );
void Write_CG_Data ( int,int );
void Write_Display_Data ( int,int,int );




I added the "main.c" to Source Files
I added the "Display_Steuerung.h" to Header Files
I added the "Display_Steuerung.c" to Other Files



Whats wrong- what does the optimal solution look like?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 12, 2008 10:39 am     Reply with quote

Don't put the #include statements all over your program. Put them
near the top, as shown below. Also put the preprocessor statements
before the #include statements. Notice the order of the statements
shown below:

1. The .H file for the PIC.
2. Any #device statements.
3. The #fuses statement.
4. The #use delay statement.
5. Any other #use statements.
6. Other #include statements.

Code:

#include <18F4620.h>
#device adc=10
#FUSES HS,NOWDT,NOPROTECT,NOPUT,NOBROWNOUT,NOLVP,NOCPD,NOWRT,DEBUG
#use delay(clock=8000000)
#use STANDARD_IO (A)
#use STANDARD_IO (B)
#use STANDARD_IO (C)
#use STANDARD_IO (D)
#use STANDARD_IO (E)

#include <string.h>
#include "Display_Steuerung.h"
#include "Display_Steuerung.c"
richi-d



Joined: 28 Aug 2007
Posts: 106

View user's profile Send private message

PostPosted: Thu Mar 13, 2008 1:03 am     Reply with quote

Thanks PCM.... o.k. this was the first step, now I get this error messages:

*** Error 12 "S:\Abteilung\AnaSys\DICE\Software\Extension_Bedienboard\Display_Steuerung.c" Line 3(12,18): Undefined identifier ENABLE
*** Error 12 "S:\Abteilung\AnaSys\DICE\Software\Extension_Bedienboard\Display_Steuerung.c" Line 10(12,15): Undefined identifier R_S
*** Error 12 "S:\Abteilung\AnaSys\DICE\Software\Extension_Bedienboard\Display_Steuerung.c" Line 11(12,15): Undefined identifier R_W
*** Error 12 "S:\Abteilung\AnaSys\DICE\Software\Extension_Bedienboard\Display_Steuerung.c" Line 12(13,19): Undefined identifier ENABLE
*** Error 12 "S:\Abteilung\AnaSys\DICE\Software\Extension_Bedienboard\Display_Steuerung.c" Line 14(12,18): Undefined identifier ENABLE


[img]C:\Clipboard_01.jpg[/img]

How must the *.h look like? Where do I declare my variables?
richi-d



Joined: 28 Aug 2007
Posts: 106

View user's profile Send private message

PostPosted: Thu Mar 13, 2008 8:54 am     Reply with quote

Is it possible to get for example a model project ( in MPLAB) where I can see how everything should be done?
Or is it possible that someone sends me a zipped model project (e-mail)

- without code...
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Mar 13, 2008 6:19 pm     Reply with quote

Quote:

now I get this error messages:
Undefined identifier ENABLE
Undefined identifier R_S
Undefined identifier R_W

I didn't realize that you have all these global variables that are used
in your other modules. To get rid of the error messages, you need to
move the two #include files so they are below all the #define statements
and the global variables.

Put them in the location shown in bold below:
Quote:

#define NOP #asm NOP #endasm;

#define LE_MUX_1 PIN_C0
#define LE_MUX_2 PIN_C1
#define LE_MUX_3 PIN_C2
#define LE_MUX_4 PIN_D7

#define CLK PIN_C3
#define DATA PIN_C5

#define LE_DATA_0 PIN_D0
#define LE_DATA_1 PIN_D1
#define LE_DATA_2 PIN_D2
#define LE_DATA_3 PIN_D3

#define AUX_LO_UL PIN_D4
#define AUX_LO_DL PIN_D5

#define PWR_DOWN PIN_D6

#define R_S PIN_E0
#define R_W PIN_E1
#define ENABLE PIN_E2

#define OUTPUT_4 PIN_A4
#define OUTPUT_5 PIN_A5
#define OUTPUT_6 PIN_A7
#define OUTPUT_7 PIN_A6

#define GEBER_1_A PIN_B0
#define GEBER_1_B PIN_B4
#define GEBER_2_A PIN_B1
#define GEBER_2_B PIN_B5

#define ENTER_1 PIN_B2
#define ENTER_2 PIN_B3


int ADRESSE;
int DATA;
int x_POS;
int y_POS;
int THOUS;
int HUNS;
int TENS;
int UNITS;
int DISPLAY_ZAHLER;

short SCHALTZUSTAND_1;


int lenght;


short STATUS_1_A;
short STATUS_1_B;
short STATUS_1_A_ALT;
short STATUS_2_A;
short STATUS_2_B;
short STATUS_2_A_ALT;

short BESTATIGT;
short ENTER_RAD_1_BIT;
short VERSTELLT;
short SPEICHERN;
short CONN_MERKER;

int TYP;
int PART;

long RAD_1;
long RAD_2;
long i;
long x;
long WERT;


#include "Display_Steuerung.h"
#include "Display_Steuerung.c"




Then you have another problem. You have both a variable and
constant with the same name, DATA. This will not work. It causes
tons of error messages:
Quote:

#define DATA PIN_C5

int DATA;


For example, you have all this code that tests 'DATA', but the bit_test()
function will not work if 'DATA' is PIN_C5. It must be a variable.
Quote:
output_bit( PIN_C0, BIT_TEST(DATA, 4));
output_bit( PIN_C1, BIT_TEST(DATA, 5));
output_bit( PIN_C2, BIT_TEST(DATA, 6));
output_bit( PIN_C3, BIT_TEST(DATA, 7));
output_high(R_S);
output_low(R_W);
output_high(ENABLE);
delay_us(10);
output_low(ENABLE);
output_bit( PIN_C0, BIT_TEST(DATA, 0));
output_bit( PIN_C1, BIT_TEST(DATA, 1));
output_bit( PIN_C2, BIT_TEST(DATA, 2));
output_bit( PIN_C3, BIT_TEST(DATA, 3));

You need to fix this problem in the Write_CG_Data() and the
Write_Display_Data() functions.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group