Author Topic: Error in AVR-GCC code...please help !  (Read 1228 times)

0 Members and 1 Guest are viewing this topic.

Offline SidJhambTopic starter

  • Beginner
  • *
  • Posts: 1
  • Helpful? 0
Error in AVR-GCC code...please help !
« on: January 22, 2012, 12:04:38 AM »
My objective is to build an rpm meter using ATmega8L.I have written the following code using timers and interrupts.


#define F_CPU 1000000UL
#include<avr/io.h>
#include<avr/interrupt.h>
#include"lcd.h"
#include"lcd.c"


volatile uint16_t count=0;
volatile uint16_t rps=0;
volatile uint16_t rpm=0;
char buffer[20];

void main()
{

DDRD=0b11110111;
lcd_init(LCD_DISP_ON);

TCCR1A|=(1<<COM1A1);
TCCR1B|=(1<<CS10)|(1<<WGM12);
TIMSK|=(1<<OCIE1A)
TCNT1H=0x00;
TCNT1L=0x00;
OCR1AH=Ox03;
OCR1AL=0xE8;

MCUCR |= (1<<ISC11)|(1<<ISC10);
GICR |= (1 << INT1);

sei();
lcd_gotoxy(0,0);

while(1)
(
sprintf(buffer,"RPM=%2d",rpm);
lcd_puts(buffer);
}

ISR(TIMER1_COMPA_vect)
{
rps=count;
rpm=rps*60;
count=0;
}

ISR(INT1_vect)
{
count++;
}

}


But it's showing the following errors.


../iitkproject.c:22: error: called object '16' is not a function

../iitkproject.c:24: error: 'Ox03' undeclared (first use in this function)
../iitkproject.c:24: error: (Each undeclared identifier is reported only once
../iitkproject.c:24: error: for each function it appears in.)
../iitkproject.c:35: error: expected ')' before ';' token
../iitkproject.c:37: error: expected ';' before '}' token
../iitkproject.c:51: error: expected identifier or '(' before '}' token
Build failed with 7 errors and 3 warnings...

Please guide me regarding this..it's urgent !!!

Offline agold

  • Jr. Member
  • **
  • Posts: 24
  • Helpful? 1
Re: Error in AVR-GCC code...please help !
« Reply #1 on: January 22, 2012, 01:47:43 AM »
"../iitkproject.c:24: error: 'Ox03' undeclared (first use in this function)"
If you look closely, you'll see that that's a capital 'O' not a zero, so change "OCR1AH=Ox03;" to "OCR1AH=0x03;"

The code:
Code: [Select]
while(1)
(    //this '(' is what I'm refering to
    sprintf(buffer,"RPM=%2d",rpm);
    lcd_puts(buffer);
}
Has a parenthesis '(' rather than a brace '{'.

According to the error "/iitkproject.c:22: error: called object '16' is not a function" your trying to call the numeral 16 on line 22 but I can't see it there so maybe it had to do with some of the other errors.
Anyway change those ones and if you get more errors read the descriptions carefully and you could probably work them out.

Adrian

 


Get Your Ad Here