7 Replies - 5056 Views - Last Post: 14 May 2011 - 10:00 AM Rate Topic: -----

#1 naresh431  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 6
  • Joined: 12-May 11

error: expected ';' before numeric constant

Posted 13 May 2011 - 09:51 PM

#include <stdlib.h> 
#include <avr/io.h>

#define lcd_port PORTB
#define lcd_wr PORTA.7
#define lcd_cs PORTA.5

void lcd_init();
void lcd_str(unsigned char* str);
void lcd_cmd(unsigned char);
void lcd_data(unsigned char);
void lcd_busy();
void delay_ms(unsigned int itime);

void main()
{   
	DDRA = 0xA0;	//making output port
	DDRB = 0x04;

	lcd_init();		//call lcd initialization
	lcd_data('A'); 	//data
	lcd_str("HELLO");	//string

}

void lcd_init()	//lcd commands
{
	lcd_cmd(0x06);   //read command
	lcd_cmd(0x05);   //write command
	lcd_cmd(0x04);   //enable/disable command
}

void lcd_cmd(unsigned char a)	//command write
{                            
	lcd_port = a;
	lcd_cs = 0;
	lcd_wr = 1;
	delay_ms(2);
}

void lcd_data(unsigned char B)/>	//command data
{                            
	lcd_port = b;
    lcd_cs = 1;
	lcd_wr = 1;
	delay_ms(2);
}

void lcd_str(unsigned char* str)
{
	while(*str)
	{
		lcd_data(*str);
		str++;
	}
}

void delay_ms(unsigned int itime)
{
	unsigned int i, j;
	for(i=0;i<itime;i++)
		for(j=0;j<135;j++);
}




View Postnaresh431, on 13 May 2011 - 09:50 PM, said:

#include <stdlib.h> 
#include <avr/io.h>

#define lcd_port PORTB
#define lcd_wr PORTA.7
#define lcd_cs PORTA.5

void lcd_init();
void lcd_str(unsigned char* str);
void lcd_cmd(unsigned char);
void lcd_data(unsigned char);
void lcd_busy();
void delay_ms(unsigned int itime);

void main()
{   
	DDRA = 0xA0;	//making output port
	DDRB = 0x04;

	lcd_init();		//call lcd initialization
	lcd_data('A'); 	//data
	lcd_str("HELLO");	//string

}

void lcd_init()	//lcd commands
{
	lcd_cmd(0x06);   //read command
	lcd_cmd(0x05);   //write command
	lcd_cmd(0x04);   //enable/disable command
}

void lcd_cmd(unsigned char a)	//command write
{                            
	lcd_port = a;
	lcd_cs = 0;
	lcd_wr = 1;
	delay_ms(2);
}

void lcd_data(unsigned char B)/>	//command data
{                            
	lcd_port = b;
    lcd_cs = 1;
	lcd_wr = 1;
	delay_ms(2);
}

void lcd_str(unsigned char* str)
{
	while(*str)
	{
		lcd_data(*str);
		str++;
	}
}

void delay_ms(unsigned int itime)
{
	unsigned int i, j;
	for(i=0;i<itime;i++)
		for(j=0;j<135;j++);
}






at here i am getting this error. pls help me out

lcd_cs = 0;
lcd_wr = 1;

Is This A Good Question/Topic? 0
  • +

Replies To: error: expected ';' before numeric constant

#2 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5230
  • View blog
  • Posts: 27,014
  • Joined: 10-May 07

Re: error: expected ';' before numeric constant

Posted 13 May 2011 - 09:53 PM

Why are you using defines? Why not just assign them as global integers?
Was This Post Helpful? 0
  • +
  • -

#3 ishkabible  Icon User is offline

  • spelling expret
  • member icon




Reputation: 1622
  • View blog
  • Posts: 5,709
  • Joined: 03-August 09

Re: error: expected ';' before numeric constant

Posted 13 May 2011 - 10:00 PM

PORTA.5

whats this?

also whats going on on lines 61 and 62, what is happening there?

...also i think we covered this in another thread. those defines your using are likely constants. you cant assign to a constant.

would this make sense.
"my name is ish" = "actually my name is no2"

it just doesn't make any sense...
Was This Post Helpful? 1
  • +
  • -

#4 naresh431  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 6
  • Joined: 12-May 11

Re: error: expected ';' before numeric constant

Posted 13 May 2011 - 10:07 PM

View Postno2pencil, on 13 May 2011 - 09:53 PM, said:

Why are you using defines? Why not just assign them as global integers?



i am beginer to C programming... Pls write the correct one...how to come out from this error
Was This Post Helpful? -1
  • +
  • -

#5 ishkabible  Icon User is offline

  • spelling expret
  • member icon




Reputation: 1622
  • View blog
  • Posts: 5,709
  • Joined: 03-August 09

Re: error: expected ';' before numeric constant

Posted 13 May 2011 - 10:19 PM

Quote

Pls write the correct one


that makes me we want to close this thread. we don't give out or correct code here as a service. that's just not how it works here.

do you understand the help we have given you? do have any questions?

people in this thread have already tried to help you with the same issue. have you read these responses? do you have questions about these responses?
Was This Post Helpful? 0
  • +
  • -

#6 naresh431  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 6
  • Joined: 12-May 11

Re: error: expected ';' before numeric constant

Posted 13 May 2011 - 10:27 PM

View Postishkabible, on 13 May 2011 - 10:19 PM, said:

Quote

Pls write the correct one


that makes me we want to close this thread. we don't give out or correct code here as a service. that's just not how it works here.

do you understand the help we have given you? do have any questions?

people in this thread have already tried to help you with the same issue. have you read these responses? do you have questions about these responses?

Ha i understood what you said in previous reply, actually i am not assigning constant to another constant. there i declared #define lcd_wr PORTA.7. (lcd_wr for portA pin 7) then how this could be as constant?
Was This Post Helpful? 0
  • +
  • -

#7 ishkabible  Icon User is offline

  • spelling expret
  • member icon




Reputation: 1622
  • View blog
  • Posts: 5,709
  • Joined: 03-August 09

Re: error: expected ';' before numeric constant

Posted 14 May 2011 - 08:43 AM

defines work differently from variable declarations. they replace what ever you tell them to in the code;

#include <iostream>

#define BEGIN {
#define END }

int main() BEGIN
   cout<<"hello world";
END



they replace whatever you tell them to replace. if you MUST have a global variable to alter you would have to declare it as an int.

static int lcd_port = PORTB;


Was This Post Helpful? 0
  • +
  • -

#8 jimblumberg  Icon User is online

  • member icon


Reputation: 4003
  • View blog
  • Posts: 12,350
  • Joined: 25-December 09

Re: error: expected ';' before numeric constant

Posted 14 May 2011 - 10:00 AM

What compiler are you using?

Jim
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1