Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Error in AVR-GCC code...please help !

Status
Not open for further replies.

SidJhamb

Newbie level 2
Joined
Jan 22, 2012
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,298
Sir my objective is to build an rpm meter using ATmega8L.I have written the following code using timers and interrupts.


Code:
#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 !!!

Looking forward to your response.

Thank you.
 
Last edited by a moderator:

I am using this code now..it is not showing any error but is not giving the required output..Can you please spot the mistake ??

#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 millisecond=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=0x03;
OCR1AL=0xE8;

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

sei();



while(1)
{
sprintf(buffer,"RPM=%2d",rpm);
lcd_puts(buffer);
}
}
ISR(TIMER1_COMPA_vect)
{
millisecond++;
if(millisecond==1000)
{
lcd_gotoxy(0,0);
rps=count;
rpm=rps*60;
millisecond=0;
count=0;
}}

ISR(INT1_vect)
{
count++;
}
 

What output do you require?

Read tutorials about avr studio
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top