Jump to content
LowFilter

Missing Semicolon Error On Main

Recommended Posts

Hi everybody!

 

here is my program:

 

#include <system.h>

#define mode PORTA.1;
#define dis1 PORTC.0;
#define dis2 PORTC.1;
#define dis3 PORTC.2;
void main()
{
TRISA = 0xFF;							//sets PORTA as input
TRISC = 0;								  //sets PORTC as output
ADCON0 = ADCON0 & 0x0E;	//A/D converter registers
ADCON0 = ADCON0 | 0x08;
ADCON1 = ADCON1 & 0xFC;
ADCON1 = ADCON1 | 0x04;
unsigned short int hundreds, tens, units, b, c, e, sel;
unsigned int sound;
unsigned int tempo;


ADCON0 = ADCON0 | 1;	 // starts AD conversion
sel = ADRES;
if(mode == 1)							   //Sound Mode
{
 if(0<=sel<=50)				//sound number detection
 {							   //
sound=1;					   //
 }							   //
 if(51<=sel<=100)				//
 {							   //
sound=2;					   //
 }							   //
 if(101<=sel<=150)			   //
 {							   //
sound=3;					   //
 }							   //
 if(151<=sel<=200)				//
 {							   //
sound=4;					   //
 }							   //
 if(201<=sel<=255)				//
 {							   //
sound=5;					   //
 }							   //end of sound number detection
 sound= sound << 4;

 dis1=1;dis2=0;dis3=0;		   //enables display 1
 PORTB = PORTB & 0x0F;			//to display 0

 dis1=0;dis2=1;dis3=0;		   //enables display 2
 PORTB = PORTB & 0x0F;			//to display 0

 dis1=0;dis2=0;dis3=1;		   //enables display 3
 PORTB = PORTB & 0x0F;
 PORTB = PORTB | sound;		 // to display sound
}
else									//Tempo Mode
{
  tempo = sel + 20;					  //Tempo detection

  hundreds = tempo / 100;				//hundreds detection
  b = hundreds * 100;
  c = Tempo - b;
  tens = c / 10;						 //tens detection
  e = tens * 10;
  units = tempo - b - e;				 //units detection

hundreds << 4;
tens << 4;
units << 4;

dis1=1;dis2=0;dis3=0;		   //enables display 1
PORTB = PORTB & 0x0F;
PORTB = PORTB | hundreds;	  // to display hundreds
dis1=0;dis2=1;dis3=0;		   //enables display 2
PORTB = PORTB & 0x0F;
PORTB = PORTB | tens;		  //to display tens
dis1=0;dis2=0;dis3=1;		   //enables display 3
PORTB = PORTB & 0x0F;
PORTB = PORTB | units;		 // to display units
}
ADCON0 = ADCON0 & 0xFE;
}

 

and here is what is written by the BoostC when I try to compile it:

 

"C:\Program Files\Matrix Multimedia\C4PICs16\sourceboost\boostc.pic16.exe" -t PIC16F77 MF1.c

BoostC Optimizing C Compiler Version 6.57 (for PIC16 architecture)

http://www.sourceboost.com

Copyright© 2004-2006 Pavel Baranov

Copyright© 2004-2006 David Hobday

Licensed to C4PICs User under Site Full License for 10 node(s)

Limitations: PIC12,PIC16 max code size:Unlimited, max RAM banks:Unlimited, Non commercial use only

 

MF1.c

failure

C:\Documents and Settings\enrsdela\My Documents\Matrix Multimedia\C4PICs16\MF1\MF1.c(7): error: missing semicolon

C:\Documents and Settings\enrsdela\My Documents\Matrix Multimedia\C4PICs16\MF1\MF1.c(7): error: failure

Failed to locate output file 'MF1.obj'

Done

Failed

 

I know this problem already happened to many people, but none of the topics already available on the forum have been helpful... help please!!!

 

Thanks :)

Edited by Pavel
added CODE tags around code

Share this post


Link to post
Share on other sites

Hi LowFilter,

 

A few basic errors:

 

Use lower case for registers, port names, tris etc.

 

Use short NOT short int

 

ADRES not defined

 

semi-colon not required after defines

 

One instance of Tempo rather than tempo

 

Good Luck!

 

davidb

Edited by davidb

Share this post


Link to post
Share on other sites

ADCON1 = ADCON1 | 0x04;
unsigned short int hundreds, tens, units, b, c, e, sel;

 

Register names are lower case. See header file.

 

A short is an int so don't declare it twice.

 

Cheers

 

Reynard

 

 

David you beat me to it :)

Edited by Reynard

Share this post


Link to post
Share on other sites

Spotted another one:

 

hundreds << 4;

tens << 4;

units << 4;

 

Incorrect syntax and will be optimised out

 

Once corrected will probably compile but whether it will do what you want is another matter!

 

Cheers

 

davidb

 

P.S Beat you to that one as well Reynard!

Share this post


Link to post
Share on other sites

if(101<=sel<=150) and similar is no good. Replace with if(101<=sel && sel<=150)

 

Remove the semicolons from the end of ALL the #defines!

Share this post


Link to post
Share on other sites
oh, and I think adres doesnt need to be defined

 

Yes, my mistake. I am so used to having more than 8-bits that ADRESL & ADRESH have become ingrained in my mind.

 

Good luck with your code

 

davidb

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...

×
×
  • Create New...