declaration syntax error in codeviion program at line 47

Status
Not open for further replies.

priyaabc

Newbie level 1
Joined
Jan 3, 2013
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,284
Code:
/*****************************************************
This program was produced by the
CodeWizardAVR V2.05.8 Evaluation
Automatic Program Generator
© Copyright 1998-2012 Pavel Haiduc, HP InfoTech s.r.l.
[url]http://www.hpinfotech.com[/url]

Project : 
Version : 
Date    : 8/15/2008
Author  : Freeware, for evaluation and
non-commercial use only
Company : 
Comments: 


Chip type               : ATmega16L
Program type            : Application
AVR Core Clock frequency: 8.000000 MHz
Memory model            : Small
External RAM size       : 0
Data Stack size         : 256
*****************************************************/

#include <mega16.h>
#include <stdio.h>
#include <delay.h>
 #asm
 .equ_lcd_port=0x18;
 #endasm             
// Alphanumeric LCD functions
#include <alcd.h>

interrupt[TIM2_OVF] void timer2_ovf_isr(void); 
char not_leap(void);
void set_time(void);
// Declare your global variables here
typedef struct{
 unsigned char second;
 unsigned char minute;
 unsigned char hour;
unsigned char date;
unsigned char month;
unsigned char year;
} time;
time t;
char lcd_buffer[40];
void sprintf(char lcd_buffer,"%u",unsigned char hour);//line 47
void main(void)
{
// Declare your local variables here

// Input/Output Ports initialization
// Port A initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out 
// State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0 
PORTA=0x00;
DDRA=0xFF;

// Port B initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out 
// State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0 
PORTB=0x00;
DDRB=0xFF;

// Port C initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out 
// State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0 
PORTC=0x00;
DDRC=0xFF;

// Port D initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In 
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T 
PORTD=0x00;
DDRD=0x00;

// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
// Mode: Normal top=0xFF
// OC0 output: Disconnected
TCCR0=0x00;
TCNT0=0x00;
OCR0=0x00;

// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer1 Stopped
// Mode: Normal top=0xFFFF
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;

// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer2 Stopped
// Mode: Normal top=0xFF
// OC2 output: Disconnected
ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;

// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
// INT2: Off
MCUCR=0x00;
MCUCSR=0x00;

// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x00;

// USART initialization
// USART disabled
UCSRB=0x00;

// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
SFIOR=0x00;

// ADC initialization
// ADC disabled
ADCSRA=0x00;

// SPI initialization
// SPI disabled
SPCR=0x00;

// TWI initialization
// TWI disabled
TWCR=0x00;

// Alphanumeric LCD initialization
// Connections are specified in the
// Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu:
// RS - PORTB Bit 0
// RD - PORTB Bit 1
// EN - PORTB Bit 2
// D4 - PORTB Bit 4
// D5 - PORTB Bit 5
// D6 - PORTB Bit 6
// D7 - PORTB Bit 7
// Characters/line: 20
lcd_init(20);
lcd_clear();
lcd_putsf("WELCOME TO ENERGY CENTRE");
set_time();
  #asm ("sei")
while (1)
      {       
      lcd_clear();
      sprintf(lcd_buffer,":%u",t.hour);
      lcd_putsf(lcd_buffer);
      sprintf(lcd_buffer,":%u",t.minute);
      lcd_putsf(lcd_buffer);
      sprintf(lcd_buffer,"%u",t.second);
      lcd_putsf(lcd_buffer);
      delay_ms(50);
      }  
}
  interrupt [TIM2_OVF] void timer2_ovf_isr(void)
    {
        if (++t.second==60)
            {
             t.second=0;
             if (++t.minute==60)
                  {
                    t.minute=0;
                    if (++t.hour==24)
                            {
                                t.hour=0;
                              if(++t.date== 32)
                              {
                              t.month++;
                              t.date=1;
                              }
                    else if (t.date==31)
                        {
                        if((t.month==4)||(t.month==6)||(t.month==9)||(t.month==11))
                         {
                            t.month++;
                            t.date=1;
                         }
                        }
                        else if (t.date==30)
                        {
                        if(t.month==2)
                            {
                                t.month++;
                                t.date=1;
                            }
                        }
                        else if (t.date==29)
                            {
                                if((t.month==2) && (not_leap()))
                                    {
                                    t.month++;
                                    t.date=1;
                                    }
                            }
                            if (t.month==13)
                                {
                                t.month=1;
                                t.year++;
                                }
                    }
        }
    }
}
char not_leap(void)
    {
        if(!(t.year%100))
            return(char)(t.year%400);
        else
            return (char)(t.year%4);
    }
void set_time(void)
    {
        lcd_clear();
        lcd_putsf("set HOUR");
        while(PIND.3==1);
        { 
            if(PIND.2==0)
                {
                    t.hour=t.hour+1;
                    if(t.hour>=24)
                    t.hour=0;
                    sprintf(lcd_buffer,"H=%u",t.hour);
                    lcd_clear();
                    lcd_puts(lcd_buffer);
                    delay_ms(100);
                }
        };

        lcd_clear();
        lcd_putsf("set MINUTE");
        delay_ms(100);
        while(PIND.3==1)
        {
            if(PIND.2==0)
                {
                    t.minute=t.minute+1;
                    if(t.minute>=60)
                    t.minute=0;
                    sprintf(lcd_buffer,"M=%u",t.minute);
                    lcd_clear();
                    lcd_puts(lcd_buffer);
                    delay_ms(100);
                }
        };
       

        lcd_clear();
        lcd_putsf("set DATE");
        delay_ms(100);
        while(PIND.3==1)
        {
            if(PIND.2==0)
                {
                    t.date=t.date+1;
                    if(t.date>=32)
                    t.date=1;
                    sprintf(lcd_buffer,"Date=%u",t.date);
                    lcd_clear();
                    lcd_puts(lcd_buffer);
                    delay_ms(100);
                }                       
        };


        lcd_clear();
        lcd_putsf("set MONTH");
        delay_ms(100);
        while(PIND.3==1)
        {
            if(PIND.2==0)
                {
                    t.month=t.month+1;
                    if(t.date>=13)
                    t.month=1;
                    sprintf(lcd_buffer,"month=%u",t.date);
                    lcd_clear();
                    lcd_puts(lcd_buffer);
                    delay_ms(100);
                }
        };

    }
 
Last edited by a moderator:

Remove line 47 completely, it serves no purpose.

Code:
void sprintf(char lcd_buffer,"%u",unsigned char hour);//line 47
 

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