Results 1 to 2 of 2

Thread: need help in coding in atmel studio 6

  1. #1
    Associate Engineer
    Join Date
    Nov 2014
    Posts
    1

    Unhappy need help in coding in atmel studio 6

    This is my code,this code is for tachometer, i am using atmel studio 6.0 it is giving error in #include"lcd.h".Please help me what to do?

    #include <avr/io.h>
    #include <avr/interrupt.h>
    #define F_CPU 1000000UL
    #include <util/delay.h>


    #include "lcd.h"
    volatile uint16_t count=0; //Main revolution counter


    volatile uint16_t rpm=0; //Revolution per minute


    volatile uint16_t rps=0; //Revolution per second




    void Wait()
    {
    uint8_t i;
    for(i=0;i<2;i++)
    {
    _delay_loop_2(0);
    }
    }




    void main()
    {
    LCDInit(LS_NONE);


    LCDWriteString("RPM Meter");



    Wait();
    Wait();
    Wait();
    Wait();


    //Init INT0
    MCUCR|=(1<<ISC01); //Falling edge on INT0 triggers interrupt.


    GICR|=(1<<INT0); //Enable INT0 interrupt


    //Timer1 is used as 1 sec time base
    //Timer Clock = 1/1024 of sys clock
    //Mode = CTC (Clear Timer On Compare)
    TCCR1B|=((1<<WGM12)|(1<<CS12)|(1<<CS10));


    //Compare value=976


    OCR1A=976;


    TIMSK|=(1<<OCIE1A); //Output compare 1A interrupt enable


    //Enable interrupts globaly
    sei();


    //LED Port as output
    DDRB|=(1<<PB1);




    LCDClear();


    LCDWriteStringXY(0,0,"RPM =");
    LCDWriteStringXY(0,1,"RPS =");


    while(1)
    {
    LCDWriteIntXY(6,0,rpm,5);
    LCDWriteIntXY(6,1,rps,5);


    if(PIND & (1<<PD2))
    {
    PORTB|=(1<<PB1);
    }
    else


    {
    PORTB&=(~(1<<PB1));
    }


    Wait();
    }


    }


    ISR(INT0_vect)
    {
    //CPU Jumps here automatically when INT0 pin detect a falling edge
    count++;
    }


    ISR(TIMER1_COMPA_vect)
    {
    //CPU Jumps here every 1 sec exactly!
    rps=count;
    rpm=rps*60;
    count=0;
    }

  2. #2
    Engineer
    Join Date
    Dec 2014
    Location
    Ohio
    Posts
    10
    May be able to help if you presented the contents of the file ("lcd.h") that contains the error.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •