Return

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

in the code below, in the LCD_getaddr function it says it returns "address", but I thought (void)'s do not return anything? Also the last line While ((LCD_getaddr... how can that be used when the LCD_getaddr returns "address". I am a newbie,I coppied this code to learn on and I'm getting a parse error right before the last "}".

code:

//LCD_getaddress reads the address counter and busy flag. For the address only,
//mask off bit7 of the return value.
char LCD_getaddr(void)
{
//make var for the return value
char address;
//PORTA is input
PORTA = 0;
//RW high, strobe enable
PORTC |= ((1<<LCD_RW)|(1<<LCD_E));
asm volatile ("nop");
asm volatile ("nop");
//while E is high, get data from LCD
address = PIND;
//reset RW to low, E low (for strobe)
PORTC &= ~((1<<LCD_RW)|(1<<LCD_E));
//return address and busy flag
return address ;
}

//LCD_wait reads the address counter (which contains the busy flag) and loops until
//the busy flag is cleared.
void LCD_wait(void)
{
//get address and busy flag
//and loop until busy flag cleared
while ((LCD_getaddr() & 0x80) == 0x80)
}

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

LCD_getaddr returns type char.

You are missing a semicolon after the last statement in LCD_wait.

C: i = "told you so";

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you take the line

char LCD_getaddr(void)

there are two type specifiers that you need to take into account.

char specifies the return type of the function. It returns an 8-bit value.
void says that there are no parameters to the function.

And just in case it is not entirely clear, it is the position of the type specifier that determines whether it is referring to the return type or the function parameters.

A

If we are not supposed to eat animals, why are they made out of meat?