a simple question about this program

Thread Starter

roberty

Joined Aug 18, 2010
11
hi every one
this program is belong to a project whit AVR (( atmega16)) and is written to controll a DC motor whit this microcontroller. i had a question about this code (( that is written in C language)) and i want you to do me a favour and answer this question
here is the program:
Rich (BB code):
#include <mega16.h>
 
// Alphanumeric LCD Module functions
#asm
   .equ __lcd_port=0x1B ;PORTA
#endasm
#include <lcd.h> 
#include<delay.h>
void display_no(int no); 
void direction(char dir);
 
void main(void)
{
 
// Input/Output Ports initialization
// Port A initialization
PORTA=0x00;
DDRA=0x00;
 
// Port B initialization
PORTB=0x00;
DDRB=0x08;
 
// Port C initialization
PORTC=0x00;
DDRC=0x00;
 
// Port D initialization
PORTD=0x00;
DDRD=0xFF;
 
// Timer/Counter 0 initialization
TCCR0=0x6A;
TCNT0=0x00;
OCR0=0x00;
 
// Timer/Counter 1 initialization
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
 
// Timer/Counter 2 initialization
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;
 
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
SFIOR=0x00;
 
// LCD module initialization
lcd_init(16);
PORTC=255;
direction(3); 
while (1)
      {
 
      if (PINC.2==0 || PINC.3==0 || PINC.4==0 ) 
      {    
          delay_ms(10); 
          if (PINC.2==0) 
                  direction(1);
          if (PINC.3==0) 
                 direction(2);
          if (PINC.4==0) 
                 direction(3);
 
       } 
 
      lcd_gotoxy(0,1);
      lcd_putsf("           ");
      lcd_gotoxy(0,1);
      lcd_putsf("OCR0: ");
      display_no(OCR0);
 
      if (PINC.0==0 || PINC.1==0 ) 
      {    
          delay_ms(10);
 
          if (PINC.0==0) 
          {     
 
              if (OCR0> 250)
                  OCR0=255; 
              else
                  OCR0=OCR0+5;
          }    
          else if (PINC.1==0) 
          {     
 
                   if(OCR0<5)
                      OCR0=0;
                   else      
                      OCR0=OCR0-5;
          }         
       }
       else
       {
 
 
       }    
 
    }
}
 
///////////////////////// 
void direction(char dir)
{
   switch(dir)
   {
         case 1:
         PORTD.0=0;
         PORTD.1=1;
         lcd_clear();
         lcd_putsf("Direction: Left ");
         break;
 
         case 2:
         PORTD.0=1;
         PORTD.1=0; 
         lcd_clear();
         lcd_putsf("Direction: Right ");
         break;
 
         case 3:
         PORTD.0=0;
         PORTD.1=0;
         lcd_clear();
         lcd_putsf("Direction: Brake ");
         break;
   }
}
/////////////////////////
void display_no(int no)
{   
   int array[5];
   int i=0,j;
   /*if( no < 0)
   {
      lcd_putchar('-');
      no=-1*no;
   }
   else
      lcd_putchar('+');*/
    while(no > 9)
    {
       array[i++]=no % 10;
       no/=10;
    }
    array=no;
    for(j=i;j >=0 ;j--)   
    {
       lcd_putchar(48+array[j]);
       delay_us(100);
       }
 
}


i want to know what are those (( pinc)) variables in LCD defination parts..??

thanks alot.
 
Top