[SOLVED] Am getting aerror as follows when i compile the program in avr

Status
Not open for further replies.

thannara123

Advanced Member level 5
Joined
Jan 7, 2010
Messages
1,600
Helped
122
Reputation
244
Reaction score
116
Trophy points
1,353
Activity points
10,602
Code:
#include <avr/io.h>
#include <inttypes.h>


#include "eeprom.h"


uint8_t EEPROMRead(uint16_t uiAddress)
{
    /* Wait for completion of previous write */
    while(EECR & (1<<EEWE));
    /* Set up address register */
    EEAR = uiAddress;
    /* Start eeprom read by writing EERE */
    EECR |= (1<<EERE);
    /* Return data from data register */
    return EEDR;
}


void EEPROMWrite(uint16_t uiAddress, uint8_t ucData)
{
    /* Wait for completion of previous write */
    while(EECR & (1<<EEWE));
    /* Set up address and data registers */
    EEAR = uiAddress;
    EEDR = ucData;
    /* Write logical one to EEMWE */
    EECR |= (1<<EEMWE);
    /* Start eeprom write by setting EEWE */
    EECR |= (1<<EEWE);
}

Build started 19.12.2012 at 09:25:40
avr-gcc.exe -mmcu=attiny2313 -Wall -gdwarf-2 -DF_CPU=1000000UL -O2 -fsigned-char -MD -MP -MT eeprom.o -MF dep/eeprom.o.d -c ../eeprom.c
../eeprom.c: In function 'EEPROMRead':
../eeprom.c:9: error: 'EEWE' undeclared (first use in this function)
../eeprom.c:9: error: (Each undeclared identifier is reported only once
../eeprom.c:9: error: for each function it appears in.)
../eeprom.c: In function 'EEPROMWrite':
../eeprom.c:21: error: 'EEWE' undeclared (first use in this function)
../eeprom.c:26: error: 'EEMWE' undeclared (first use in this function)
make: *** [eeprom.o] Error 1
Build failed with 5 errors and 0 warnings...



â​How can i rectify ?.

- - - Updated - - -

yes I got and changed as follows
Code:
#include <avr/io.h>
#include <inttypes.h>

#include "eeprom.h"

uint8_t EEPROMRead(uint16_t uiAddress)
{
	/* Wait for completion of previous write */
	while(EECR & (1<<EEPE));
	/* Set up address register */
	EEAR = uiAddress;
	/* Start eeprom read by writing EERE */
	EECR |= (1<<EERE);
	/* Return data from data register */
	return EEDR;
}

void EEPROMWrite(uint16_t uiAddress, uint8_t ucData)
{
	/* Wait for completion of previous write */
	while(EECR & (1<<EEPE));
	/* Set up address and data registers */
	EEAR = uiAddress;
	EEDR = ucData;
	/* Write logical one to EEMWE */
	EECR |= (1<<EEMPE);
	/* Start eeprom write by setting EEWE */
	EECR |= (1<<EEPE);
}
 

Yes sir ,


Code:
#include <avr/io.h>
#include <inttypes.h>

#include "eeprom.h"

uint8_t EEPROMRead(uint16_t uiAddress)
{
	/* Wait for completion of previous write */
	[COLOR="#FF0000"]while(EECR & (1<<EEPE));[/COLOR]      // changed 
	/* Set up address register */
	EEAR = uiAddress;
	/* Start eeprom read by writing EERE */
	EECR |= (1<<EERE);
	/* Return data from data register */
	return EEDR;
}

void EEPROMWrite(uint16_t uiAddress, uint8_t ucData)
{
	/* Wait for completion of previous write */
	while(EECR & (1<<EEPE));
	/* Set up address and data registers */
	EEAR = uiAddress;
	EEDR = ucData;
	/* Write logical one to EEMWE */
	EECR |= (1<<EEMPE);
	/* Start eeprom write by setting EEWE */
	[COLOR="#FF0000"][COLOR="#FF0000"]EECR |= (1<<EEPE);[/COLOR][/COLOR]
}
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…