i am getting 7 errors and telling that expected ; before numeric const

  • (2 Pages)
  • +
  • 1
  • 2

17 Replies - 1092 Views - Last Post: 26 September 2014 - 11:11 AM Rate Topic: -----

#1 Faruque_ali  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 25-September 14

i am getting 7 errors and telling that expected ; before numeric const

Posted 25 September 2014 - 05:58 AM

#include <delay.h>

#define red_1 PORTA.0
#define yellow_1 PORTA.1
#define green_1 PORTA.2
#define red_2 PORTA.3
#define yellow_2 PORTA.4
#define green_2 PORTA.5
#define green_a PORTA.6
#define red_a PORTA.7
#define green_b PORTB.0
#define red_b PORTB.1

unsigned char a,b;



unsigned char segment (unsigned char input){
switch(input){
	case 1:{return 0x06;break;}
	case 2:{return 0x5B;break;}
	case 3:{return 0x4F;break;}
	case 4:{return 0x66;break;}
	case 5:{return 0x6D;break;}
	case 6:{return 0x7D;break;}
	case 7:{return 0x07;break;}
	case 8:{return 0x7F;break;} 
	case 9:{return 0x6F;break;}
	case 0:{return 0x3F;break;}
}
}

void delay_green(void){     
	red_a=0;
    green_b=0;
    a=9;
    b=0;
    while(b!=10){
		delay_ms(1000);
		b++;            
		PORTC=segment(a);
		green_a=1;
		red_b=1;
		a--;
    }
	a=9;
}
      
      
void delay_red(void){     
    green_a=0;
    red_b=0;
    a=9;
    b=0;
    while(b!=10){
      
    delay_ms(1000);
    b++;            
    PORTC=segment(a);
    red_a=1;
    green_b=1;
    a--;
}
}


void main(void){
PORTA=0x00;
DDRA=0xFF;
PORTB=0x00;
DDRB=0x03;
PORTC=0x00;
DDRC=0xFF;
PORTD=0x00;
DDRD=0xFF;


while (1)
      {     
      red_1=0;
      red_2=1;
      green_1=1;
      delay_green();
      green_1=0;
      yellow_1=1;
      delay_ms(1500);
      yellow_1=0;
      red_1=1;
      red_2=0;
      green_2=1;
      delay_red(); 
      yellow_2=1;
      green_2=0;
      delay_ms(1500);
      yellow_2=0;
      };
}


This post has been edited by vividexstance: 25 September 2014 - 06:28 AM
Reason for edit:: Put code in code tags. Learn to do this yourself.


Is This A Good Question/Topic? 0
  • +

Replies To: i am getting 7 errors and telling that expected ; before numeric const

#2 DarenR  Icon User is offline

  • D.I.C Lover

Reputation: 593
  • View blog
  • Posts: 3,823
  • Joined: 12-January 10

Re: i am getting 7 errors and telling that expected ; before numeric const

Posted 25 September 2014 - 06:07 AM

remove the ; from

delay_ms(1500);
yellow_2=0;
};

Was This Post Helpful? 0
  • +
  • -

#3 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 6016
  • View blog
  • Posts: 20,701
  • Joined: 05-May 12

Re: i am getting 7 errors and telling that expected ; before numeric const

Posted 25 September 2014 - 06:29 AM

Post the exact errors you are getting.
Was This Post Helpful? 0
  • +
  • -

#4 Faruque_ali  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 25-September 14

Re: i am getting 7 errors and telling that expected ; before numeric const

Posted 25 September 2014 - 06:46 AM

nw i am getting three errors saying tat expected ; before numeric constant?

error is showing in green_a=0 tat expected ; before numeric constant
and same case showing for red_a=0
and telling in function'delay_red"?can u please help me
Was This Post Helpful? 0
  • +
  • -

#5 jimblumberg  Icon User is online

  • member icon

Reputation: 5398
  • View blog
  • Posts: 16,829
  • Joined: 25-December 09

Re: i am getting 7 errors and telling that expected ; before numeric const

Posted 25 September 2014 - 07:11 AM

You need to post the complete error message, these messages will have more information than what you're showing. One item is the line number where the error was detected.

Jim
Was This Post Helpful? 0
  • +
  • -

#6 Faruque_ali  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 25-September 14

Re: i am getting 7 errors and telling that expected ; before numeric const

Posted 25 September 2014 - 07:31 AM

../modified_tls.c:40: error: expected ';' before numeric constant
../modified_tls.c: In function 'delay_red':
then shows red arrow in red_a=0
../modified_tls.c:57: error: expected ';' before numeric constant
../modified_tls.c: At top level:
then shows red arrow in green_a=0
../modified_tls.c:86: error: expected ';' before numeric constant
make: *** [modified_tls.o] Error 1
then shows red arrow in red _1=0
now can u help me these are the three errors i hve shown u
Was This Post Helpful? 0
  • +
  • -

#7 jimblumberg  Icon User is online

  • member icon

Reputation: 5398
  • View blog
  • Posts: 16,829
  • Joined: 25-December 09

Re: i am getting 7 errors and telling that expected ; before numeric const

Posted 25 September 2014 - 08:16 AM

Your errors are probably being caused by the following:
#define red_1 PORTA.0
#define yellow_1 PORTA.1
#define green_1 PORTA.2
#define red_2 PORTA.3
#define yellow_2 PORTA.4
#define green_2 PORTA.5
#define green_a PORTA.6
#define red_a PORTA.7
#define green_b PORTB.0
#define red_b PORTB.1


What compiler are you using?

Where is PORTA defined?

Jim
Was This Post Helpful? 0
  • +
  • -

#8 Faruque_ali  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 25-September 14

Re: i am getting 7 errors and telling that expected ; before numeric const

Posted 26 September 2014 - 07:40 AM

i am writing program in avr studio 4
so can u please help me removing the three errors???
Was This Post Helpful? 0
  • +
  • -

#9 jimblumberg  Icon User is online

  • member icon

Reputation: 5398
  • View blog
  • Posts: 16,829
  • Joined: 25-December 09

Re: i am getting 7 errors and telling that expected ; before numeric const

Posted 26 September 2014 - 07:59 AM

Can you please answer all the questions posed? Show how and where PORTA is defined. Have you tried to just use PORTA.0 instead of red_1?



Jim
Was This Post Helpful? 0
  • +
  • -

#10 Faruque_ali  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 25-September 14

Re: i am getting 7 errors and telling that expected ; before numeric const

Posted 26 September 2014 - 08:31 AM

#ifndef F_CPU
# define F_CPU 1000000UL
#endif

#include<avr/io.h>
#include <util/delay.h>
#define red_1 PORTA.0
#define yellow_1 PORTA.1
#define green_1 PORTA.2
#define red_2 PORTA.3
#define yellow_2 PORTA.4
#define green_2 PORTA.5
#define green_a PORTA.6
#define red_a PORTA.7
#define green_b PORTB.0
#define red_b PORTB.1

unsigned char a,b;



unsigned char segment (unsigned char input)
{
switch(input){
	case 1:{return 0x06;break;}
	case 2:{return 0x5B;break;}
	case 3:{return 0x4F;break;}
	case 4:{return 0x66;break;}
	case 5:{return 0x6D;break;}
	case 6:{return 0x7D;break;}
	case 7:{return 0x07;break;}
	case 8:{return 0x7F;break;} 
	case 9:{return 0x6F;break;}
	case 0:{return 0x3F;break;}
}
}

void delay_green(void)
{     
	red_a=0
    green_b=0
    a=9
    b=0
    while(b!=10){
		delay_ms(1000)
		b++;            
		PORTC=segment(a);
		green_a=1
		red_b=1
		a--;
    }
	a=9
}
      
      
void delay_red(void){     
    green_a=0
     red_b=0
    a=9
    b=0
    while(b!=10){
      
    delay_ms(1000)
    b++;           
    PORTC=segment(a);
    red_a=1
    green_b=1
    a--;
}
}


int main(void){
PORTA=0x00;
DDRA=0xFF;
PORTB=0x00;
DDRB=0x03;
PORTC=0x00;
DDRC=0xFF;
PORTD=0x00;
DDRD=0xFF;


while (1)
      {     
      red_1=0
       red_2=1
       green_1=1
      delay_green()
       green_1=0
      yellow_1=1
      delay_ms(1500)
      yellow_1=0
      red_1=1
      red_2=0
      green_2=1
      delay_red() 
      yellow_2=1
      green_2=0
      delay_ms(1500)
      yellow_2=0
      }
}

in this way i hve written the program and showing three erroers that i hve told u b4

so can u please help me out i need it urgently?
if u dont mind

This post has been edited by jimblumberg: 26 September 2014 - 09:18 AM
Reason for edit:: Added missing code tags please learn to use them properly.

Was This Post Helpful? 0
  • +
  • -

#11 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 1437
  • View blog
  • Posts: 4,626
  • Joined: 20-March 10

Re: i am getting 7 errors and telling that expected ; before numeric const

Posted 26 September 2014 - 08:37 AM

Try this and see if this works.

#include <mega16.h>
#include <delay.h>

PORTA=0x00;
DDRA=0xFF;
PORTB=0x00;
DDRB=0x03;
PORTC=0x00;
DDRC=0xFF;
PORTD=0x00;
DDRD=0xFF;

#define red_1 PORTA.0
#define yellow_1 PORTA.1
#define green_1 PORTA.2
#define red_2 PORTA.3
#define yellow_2 PORTA.4
#define green_2 PORTA.5
#define green_a PORTA.6
#define red_a PORTA.7
#define green_b PORTB.0
#define red_b PORTB.1

unsigned char a,b;



unsigned char segment (unsigned char input){
switch(input){
	case 1:{return 0x06;break;}
	case 2:{return 0x5B;break;}
	case 3:{return 0x4F;break;}
	case 4:{return 0x66;break;}
	case 5:{return 0x6D;break;}
	case 6:{return 0x7D;break;}
	case 7:{return 0x07;break;}
	case 8:{return 0x7F;break;} 
	case 9:{return 0x6F;break;}
	case 0:{return 0x3F;break;}
}
}

void delay_green(void){     
	red_a=0;
    green_b=0;
    a=9;
    b=0;
    while(b!=10){
		delay_ms(1000);
		b++;            
		PORTC=segment(a);
		green_a=1;
		red_b=1;
		a--;
    }
	a=9;
}
      
      
void delay_red(void){     
    green_a=0;
    red_b=0;
    a=9;
    b=0;
    while(b!=10){
      
    delay_ms(1000);
    b++;            
    PORTC=segment(a);
    red_a=1;
    green_b=1;
    a--;
}
}


void main(void){



while (1)
      {     
      red_1=0;
      red_2=1;
      green_1=1;
      delay_green();
      green_1=0;
      yellow_1=1;
      delay_ms(1500);
      yellow_1=0;
      red_1=1;
      red_2=0;
      green_2=1;
      delay_red(); 
      yellow_2=1;
      green_2=0;
      delay_ms(1500);
      yellow_2=0;
      };
}



If it doesnt please post your updated code, we cant possibly help you if you dont post your updated code with the exact error as it appears in avr studio.

Regards

Snoopy.
Was This Post Helpful? 0
  • +
  • -

#12 jimblumberg  Icon User is online

  • member icon

Reputation: 5398
  • View blog
  • Posts: 16,829
  • Joined: 25-December 09

Re: i am getting 7 errors and telling that expected ; before numeric const

Posted 26 September 2014 - 09:21 AM

Quote

in this way i hve written the program and showing three erroers that i hve told u b4

so can u please help me out i need it urgently?


How can I help you if you won't answer my questions?

You need to realize that most people will not have access to your compiler and will not be able to properly compile your code.

Did you do what I asked?

Quote

Where is PORTA defined?


Quote

Have you tried to just use PORTA.0 instead of red_1?


Jim
Was This Post Helpful? 0
  • +
  • -

#13 Faruque_ali  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 25-September 14

Re: i am getting 7 errors and telling that expected ; before numeric const

Posted 26 September 2014 - 09:29 AM

Build started 26.9.2014 at 21:56:10
avr-gcc.exe -mmcu=atmega16 -Wall -gdwarf-2 -Os -std=gnu99 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT ex_tls.o -MF dep/ex_tls.o.d -c ../ex_tls.c
In file included from ../ex_tls.c:2:
c:/winavr-20080610/lib/gcc/../../avr/include/util/delay.h:85:3: warning: #warning "F_CPU not defined for <util/delay.h>"
../ex_tls.c:3: warning: data definition has no type or storage class
../ex_tls.c:3: warning: type defaults to 'int' in declaration of 'PORTA'
../ex_tls.c:4: warning: data definition has no type or storage class
../ex_tls.c:4: warning: type defaults to 'int' in declaration of 'DDRA'
../ex_tls.c:5: warning: data definition has no type or storage class
../ex_tls.c:5: warning: type defaults to 'int' in declaration of 'PORTB'
../ex_tls.c:6: warning: data definition has no type or storage class
../ex_tls.c:6: warning: type defaults to 'int' in declaration of 'DDRB'
../ex_tls.c:7: warning: data definition has no type or storage class
../ex_tls.c:7: warning: type defaults to 'int' in declaration of 'PORTC'
../ex_tls.c:8: warning: data definition has no type or storage class
../ex_tls.c:8: warning: type defaults to 'int' in declaration of 'DDRC'
../ex_tls.c:9: warning: data definition has no type or storage class
../ex_tls.c:9: warning: type defaults to 'int' in declaration of 'PORTD'
../ex_tls.c:10: warning: data definition has no type or storage class
../ex_tls.c:10: warning: type defaults to 'int' in declaration of 'DDRD'
../ex_tls.c: In function 'delay_green':
../ex_tls.c:54: warning: statement with no effect
../ex_tls.c:54: error: expected ';' before numeric constant
../ex_tls.c:56: warning: statement with no effect
../ex_tls.c:56: error: expected ';' before numeric constant
../ex_tls.c:63: warning: implicit declaration of function 'delay_ms'
../ex_tls.c:69: warning: statement with no effect
../ex_tls.c:69: error: expected ';' before numeric constant
../ex_tls.c:71: warning: statement with no effect
../ex_tls.c:71: error: expected ';' before numeric constant
../ex_tls.c: In function 'delay_red':
../ex_tls.c:84: warning: statement with no effect
../ex_tls.c:84: error: expected ';' before numeric constant
../ex_tls.c:86: warning: statement with no effect
../ex_tls.c:86: error: expected ';' before numeric constant
../ex_tls.c:102: warning: statement with no effect
../ex_tls.c:102: error: expected ';' before numeric constant
../ex_tls.c:104: warning: statement with no effect
../ex_tls.c:104: error: expected ';' before numeric constant
../ex_tls.c: At top level:
../ex_tls.c:111: warning: return type of 'main' is not 'int'
../ex_tls.c: In function 'main':
../ex_tls.c:117: warning: statement with no effect
../ex_tls.c:117: error: expected ';' before numeric constant
../ex_tls.c:119: warning: statement with no effect
../ex_tls.c:119: error: expected ';' before numeric constant
../ex_tls.c:121: warning: statement with no effect
../ex_tls.c:121: error: expected ';' before numeric constant
../ex_tls.c:125: warning: statement with no effect
../ex_tls.c:125: error: expected ';' before numeric constant
../ex_tls.c:127: warning: statement with no effect
../ex_tls.c:127: error: expected ';' before numeric constant
../ex_tls.c:131: warning: statement with no effect
../ex_tls.c:131: error: expected ';' before numeric constant
../ex_tls.c:133: warning: statement with no effect
../ex_tls.c:133: error: expected ';' before numeric constant
../ex_tls.c:135: warning: statement with no effect
../ex_tls.c:135: error: expected ';' before numeric constant
../ex_tls.c:137: warning: statement with no effect
../ex_tls.c:137: error: expected ';' before numeric constant
../ex_tls.c:141: warning: statement with no effect
../ex_tls.c:141: error: expected ';' before numeric constant
../ex_tls.c:143: warning: statement with no effect
../ex_tls.c:143: error: expected ';' before numeric constant
../ex_tls.c:147: warning: statement with no effect
../ex_tls.c:147: error: expected ';' before numeric constant
make: *** [ex_tls.o] Error 1
Build failed with 20 errors and 39 warnings...
these errors i am getting
Was This Post Helpful? 0
  • +
  • -

#14 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 1437
  • View blog
  • Posts: 4,626
  • Joined: 20-March 10

Re: i am getting 7 errors and telling that expected ; before numeric const

Posted 26 September 2014 - 09:37 AM

Have you included

#include <mega16.h>


header file

Snoopy.
Was This Post Helpful? 0
  • +
  • -

#15 Faruque_ali  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 25-September 14

Re: i am getting 7 errors and telling that expected ; before numeric const

Posted 26 September 2014 - 10:35 AM

yes i hve included but then also errors i hve send u all the exact errors tat are showing in my compiler

yes i hve included but then also errors i hve send u all the exact erroers tat are showing in my compiler
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2