Can anyone tell whether the program is correct..

Discussion in 'Programmer's Corner' started by nirmal_rockin, Sep 12, 2009.

  1. nirmal_rockin

    Thread Starter Member

    Aug 7, 2009
    19
    0
    Hi i'm getting two errors in this program
    "Warning: C:\Documents and Settings\Administrator\Desktop\Line follower.c(178): function parameter 'delay' was not referenced"
    "Warning: C:\Documents and Settings\Administrator\Desktop\Line follower.c(178): function parameter 'power' was not referenced"
    i'm using code vision avr compiler to execute the program..
    some one pls help.... i'm in an urgency.....
    thank you
     
  2. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    In the function move(); you failed to use the two variables "delay" and "power" that are passed to the function.

    hgmjr
     
  3. someonesdad

    Senior Member

    Jul 7, 2009
    1,585
    141
    Those are warnings, not errors, so the program should compile OK. The compiler is just telling you that some parameters haven't been used (so it's indirectly asking you why they are in the parameter list.
     
  4. nirmal_rockin

    Thread Starter Member

    Aug 7, 2009
    19
    0
    yes, but when i burned it into the mc.. i don get any o/p from the mc and i don't know what is the problem with the program..

    the sensors are working fine but no output
    some one pls help resolving my problem...
     
  5. nirmal_rockin

    Thread Starter Member

    Aug 7, 2009
    19
    0
    does configuring the fuses matter much????
     
  6. nirmal_rockin

    Thread Starter Member

    Aug 7, 2009
    19
    0
    can any one help me... i feel the following program in not complete...the program executes with two warnings...but i don get any out put from the mc....some one pls tell me whether the program is correct and if it is complete(htis program was not written by me i got it from the net)...
    thanks in advance
    this is the schematic for the line follower the input is through the sensors and the output is to the motor driver my problem is i don get any output from the mc......
    [​IMG]

     
    Last edited: Sep 17, 2009
  7. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    Can you give us a description of what the program is intended to do?

    hgmjr
     
  8. nirmal_rockin

    Thread Starter Member

    Aug 7, 2009
    19
    0
    I hav added the schematic and the problem sir... pls help me......
     
  9. nirmal_rockin

    Thread Starter Member

    Aug 7, 2009
    19
    0
    i always get a high output from the pins 24 and 25 of the mc...does anyone know wat the problem is...
     
  10. nanovate

    Distinguished Member

    May 7, 2007
    665
    1
    Check your fuse settings to make sure JTAG is NOT enabled.
     
  11. nirmal_rockin

    Thread Starter Member

    Aug 7, 2009
    19
    0
    sir but how do i disable the jtag interface....i'm totally new to this...but i've learnt a lot recently and have to learn more...pls help....
     
  12. nanovate

    Distinguished Member

    May 7, 2007
    665
    1
    What compiler/IDE are you using?

    In AVRStudio there is a programming interface that allows you change the fuse settings.

    Look at the Memory Programming Section of the datasheet for info on the fuse settings
     
  13. nirmal_rockin

    Thread Starter Member

    Aug 7, 2009
    19
    0
    i'm using codevision avr for compiling the pgm....
     
  14. nanovate

    Distinguished Member

    May 7, 2007
    665
    1
    Codevision has an interface in their IDE
    or
    you can write and compile in codevision then use AVRStudio.

    What programmer are you using?
     
  15. nirmal_rockin

    Thread Starter Member

    Aug 7, 2009
    19
    0
    but if i compile in avr studio i get an error specifying tat "missing seperator" in the delay.h file... but if i compile in codevision the file executes fine...

    i use pony prog for programming...in a devolopment board given to me by our college....
     
  16. nanovate

    Distinguished Member

    May 7, 2007
    665
    1
    You doubt my advice from the other thread?

    http://forum.allaboutcircuits.com/showthread.php?t=27770

    You have output pins located on the JTAG interface.

    Fuse settings determine the oscillator settings, the boot section, etc... I'd say they matter just a little bit
     
  17. nanovate

    Distinguished Member

    May 7, 2007
    665
    1
    your code is for CodeVision. Please read the documentation on how to program the fuses
     
  18. nirmal_rockin

    Thread Starter Member

    Aug 7, 2009
    19
    0
    if i could change the 24th and 25th pins to 28th and 29th pins what change should i do in the program????
     
  19. nanovate

    Distinguished Member

    May 7, 2007
    665
    1
    First please repost the code using the "CODE" tags and with proper indenting so that it is readable.
    Second, are you sure that the code matches the schematic? I see writes to PORTC in the move() function but PORTC doesn't have corresponding pins to be affected. Maybe I am sleepy but it doesn't match up.
     
  20. nirmal_rockin

    Thread Starter Member

    Aug 7, 2009
    19
    0
    yes that is the problem can you tell how do i configure the pins of port c..wat is the code wch i should write to initialize the 4 pins of port c...

    Code ( (Unknown Language)):
    1. /*****************************************************
    2. Project : Line Follower
    3. Version :
    4. Date : 2/19/2006
    5. Author : Nirmal
    6. Company : Home
    7. Comments:
    8. Chip type : ATmega16L
    9. Program type : Application
    10. Clock frequency : 7.372800 MHz
    11. Memory model : Small
    12. External SRAM size : 0
    13. Data Stack size : 256
    14. *****************************************************/
    15. //#define debug 1
    16. #include <mega16.h>
    17. #include <delay.h>
    18. #ifdef debug
    19. #include <stdio.h>
    20. #endif
    21. #define FWD 0xAA
    22. #define REV 0x55
    23. #define R 0x22
    24. #define L 0x88
    25. #define CW 0x99
    26. #define CCW 0x66
    27. #define STOP 0x00
    28. #define B 0xFF
    29. #define RSPEED OCR1AL
    30. #define LSPEED OCR1BL
    31. #define SPEED0 255
    32. #define SPEED1 0
    33. #define SPEED2 0
    34. #define SPEED3 0
    35. #define MAX 3
    36. #define HMAX 1
    37. void move (unsigned char dir,unsigned char delay,unsigned char power);
    38. unsigned char i,rdev,ldev,ip,delay,dir,power,dirl,history[MAX],hcount=0,rotpow;
    39. #ifdef debug
    40. unsigned char rep=0,prev=0;
    41. #endif
    42. void main(void)
    43. {
    44. // Input/Output Ports initialization
    45. // Port A initialization
    46. // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
    47. // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
    48.      PORTA=0x00;
    49.      DDRA=0x00;
    50. // Port B initialization
    51. // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
    52. // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
    53.      PORTB=0x00;
    54.      DDRB=0x00;
    55. // Port C initialization
    56. // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
    57. // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
    58.      PORTC=0x00;
    59.      DDRC=0xFF;
    60. // Port D initialization
    61. // Func7=In Func6=In Func5=Out Func4=Out Func3=In Func2=In Func1=In Func0=In
    62. // State7=T State6=T State5=0 State4=0 State3=T State2=T State1=T State0=T
    63.      PORTD=0x00;
    64.      DDRD=0x30;
    65. // Timer/Counter 0 initialization
    66. // Clock source: System Clock
    67. // Clock value: Timer 0 Stopped
    68. // Mode: Normal top=FFh
    69. // OC0 output: Disconnected
    70.      TCCR0=0x00;
    71.      TCNT0=0x00;
    72.      OCR0=0x00;
    73. // Timer/Counter 1 initialization
    74. // Clock source: System Clock
    75. // Clock value: 921.600 kHz
    76. // Mode: Fast PWM top=00FFh
    77. // OC1A output: Non-Inv.
    78. // OC1B output: Non-Inv.
    79. // Noise Canceler: Off
    80. // Input Capture on Falling Edge
    81.      TCCR1A=0xA1;
    82.      TCCR1B=0x0A;
    83.      TCNT1H=0x00;
    84.      TCNT1L=0x00;
    85.      ICR1H=0x00;
    86.      ICR1L=0x00;
    87.      OCR1AH=0x00;
    88.      OCR1AL=0xFF;
    89.      OCR1BH=0x00;
    90.      OCR1BL=0xFF;
    91. // Timer/Counter 2 initialization
    92. // Clock source: System Clock
    93. // Clock value: Timer 2 Stopped
    94. // Mode: Normal top=FFh
    95. // OC2 output: Disconnected
    96.      ASSR=0x00;
    97.      TCCR2=0x00;
    98.      TCNT2=0x00;
    99.      OCR2=0x00;
    100. // External Interrupt(s) initialization
    101. // INT0: Off
    102. // INT1: Off
    103. // INT2: Off
    104.      MCUCR=0x00;
    105.      MCUCSR=0x00;
    106.    #ifdef debug
    107. // USART initialization
    108. // Communication Parameters: 8 Data, 1 Stop, No Parity
    109. // USART Receiver: On
    110. // USART Transmitter: On
    111. // USART Mode: Asynchronous
    112. // USART Baud rate: 57600
    113.      UCSRA=0x00;
    114.      UCSRB=0x18;
    115.      UCSRC=0x86;
    116.      UBRRH=0x00;
    117.      UBRRL=0x07;
    118.   #endif
    119. // Timer(s)/Counter(s) Interrupt(s) initialization
    120.      TIMSK=0x00;
    121. // Analog Comparator initialization
    122. // Analog Comparator: Off
    123. // Analog Comparator Input Capture by Timer/Counter 1: Off
    124.      ACSR=0x80;
    125.      SFIOR=0x00;
    126. while (1)
    127. {
    128. #ifdef debug
    129.    if(rep<255)
    130. rep++;
    131.    if(prev!=PINA)
    132. {
    133.   prev=PINA;
    134. printf("%u\r",rep);
    135.    for(i=0;i<8;i++)
    136. printf("%u\t",(prev>>i)&0x01);
    137.   rep=0;
    138. }
    139. #endif
    140.    if(PINA!=255)
    141. {
    142.        rotpow=255;
    143. ldev=rdev=0;
    144.    if(PINA.3==0)
    145. rdev=1;
    146.    if(PINA.2==0)
    147. rdev=2;
    148.    if(PINA.1==0)
    149. rdev=3;
    150.    if(PINA.0==0)
    151. rdev=4;
    152.    if(PINA.4==0)
    153. ldev=1;
    154.    if(PINA.5==0)
    155. ldev=2;
    156.    if(PINA.6==0)
    157. ldev=3;
    158.    if(PINA.7==0)
    159. ldev=4;
    160.    if(rdev>ldev)
    161.           move(R,0,195+12*rdev);
    162.    if(rdev<ldev)
    163.           move(L,0,195+12*ldev);
    164.    if(rdev==ldev)
    165.           move(FWD,0,200);
    166. }
    167.    else
    168. {
    169.    for(i=0,dirl=0;i<MAX;i++)
    170. {
    171.    if(history[i]==L)
    172. {
    173.       dirl++;
    174. }
    175. }
    176.    if(rotpow<160)
    177. {
    178.       rotpow=160;
    179. }
    180.    if(rotpow<255)
    181. {
    182.       rotpow++;
    183. }
    184.    if(dirl>HMAX)
    185. {
    186.       move(CW,0,rotpow);
    187. }
    188.    else
    189. {
    190.       move(CCW,0,rotpow);
    191. }
    192. }
    193. };
    194. }
    195. void move (unsigned char dir,unsigned char delay,unsigned char power)
    196. {
    197. PORTC=dir;
    198.     if(dir==L || dir==R)
    199. {
    200. hcount=(hcount+1)%MAX;
    201. history[hcount]=dir;
    202. }
    203. LSPEED=RSPEED=255;//power;
    204. //delay_ms(delay);
    205. }[/i]
    Code ( (Unknown Language)):
    1. Mega16.h
    2. // CodeVisionAVR V2.0 C Compiler
    3. // (C) 1998-2009 Pavel Haiduc, HP InfoTech S.R.L.
    4.  
    5. // I/O registers definitions for the ATmega16
    6.  
    7. #ifndef _MEGA16_INCLUDED_
    8. #define _MEGA16_INCLUDED_
    9.  
    10. #pragma used+
    11. sfrb TWBR=0;
    12. sfrb TWSR=1;
    13. sfrb TWAR=2;
    14. sfrb TWDR=3;
    15. sfrb ADCL=4;
    16. sfrb ADCH=5;
    17. sfrw ADCW=4;      // 16 bit access
    18. sfrb ADCSRA=6;
    19. sfrb ADMUX=7;
    20. sfrb ACSR=8;
    21. sfrb UBRRL=9;
    22. sfrb UCSRB=0xa;
    23. sfrb UCSRA=0xb;
    24. sfrb UDR=0xc;
    25. sfrb SPCR=0xd;
    26. sfrb SPSR=0xe;
    27. sfrb SPDR=0xf;
    28. sfrb PIND=0x10;
    29. sfrb DDRD=0x11;
    30. sfrb PORTD=0x12;
    31. sfrb PINC=0x13;
    32. sfrb DDRC=0x14;
    33. sfrb PORTC=0x15;
    34. sfrb PINB=0x16;
    35. sfrb DDRB=0x17;
    36. sfrb PORTB=0x18;
    37. sfrb PINA=0x19;
    38. sfrb DDRA=0x1a;
    39. sfrb PORTA=0x1b;
    40. sfrb EECR=0x1c;
    41. sfrb EEDR=0x1d;
    42. sfrb EEARL=0x1e;
    43. sfrb EEARH=0x1f;
    44. sfrw EEAR=0x1e;   // 16 bit access
    45. sfrb UBRRH=0x20;
    46. sfrb UCSRC=0X20;
    47. sfrb WDTCR=0x21;
    48. sfrb ASSR=0x22;
    49. sfrb OCR2=0x23;
    50. sfrb TCNT2=0x24;
    51. sfrb TCCR2=0x25;
    52. sfrb ICR1L=0x26;
    53. sfrb ICR1H=0x27;
    54. sfrb OCR1BL=0x28;
    55. sfrb OCR1BH=0x29;
    56. sfrw OCR1B=0x28;  // 16 bit access
    57. sfrb OCR1AL=0x2a;
    58. sfrb OCR1AH=0x2b;
    59. sfrw OCR1A=0x2a;  // 16 bit access
    60. sfrb TCNT1L=0x2c;
    61. sfrb TCNT1H=0x2d;
    62. sfrw TCNT1=0x2c;  // 16 bit access
    63. sfrb TCCR1B=0x2e;
    64. sfrb TCCR1A=0x2f;
    65. sfrb SFIOR=0x30;
    66. sfrb OSCCAL=0x31;
    67. sfrb OCDR=0x31;
    68. sfrb TCNT0=0x32;
    69. sfrb TCCR0=0x33;
    70. sfrb MCUCSR=0x34;
    71. sfrb MCUCR=0x35;
    72. sfrb TWCR=0x36;
    73. sfrb SPMCR=0x37;
    74. sfrb TIFR=0x38;
    75. sfrb TIMSK=0x39;
    76. sfrb GIFR=0x3a;
    77. sfrb GICR=0x3b;
    78. sfrb OCR0=0X3c;
    79. sfrb SPL=0x3d;
    80. sfrb SPH=0x3e;
    81. sfrb SREG=0x3f;
    82. #pragma used-
    83.  
    84. // Interrupt vectors definitions
    85.  
    86. #define EXT_INT0 2
    87. #define EXT_INT1 3
    88. #define TIM2_COMP 4
    89. #define TIM2_OVF 5
    90. #define TIM1_CAPT 6
    91. #define TIM1_COMPA 7
    92. #define TIM1_COMPB 8
    93. #define TIM1_OVF 9
    94. #define TIM0_OVF 10
    95. #define SPI_STC 11
    96. #define USART_RXC 12
    97. #define USART_DRE 13
    98. #define USART_TXC 14
    99. #define ADC_INT 15
    100. #define EE_RDY 16
    101. #define ANA_COMP 17
    102. #define TWI 18
    103. #define EXT_INT2 19
    104. #define TIM0_COMP 20
    105. #define SPM_READY 21
    106.  
    107. // Needed by the power management functions (sleep.h)
    108. #define __SLEEP_SUPPORTED__
    109. #define __POWERDOWN_SUPPORTED__
    110. #define __POWERSAVE_SUPPORTED__
    111. #define __STANDBY_SUPPORTED__
    112. #define __EXTENDED_STANDBY_SUPPORTED__
    113. #asm
    114.     #ifndef __SLEEP_DEFINED__
    115.     #define __SLEEP_DEFINED__
    116.     .EQU __se_bit=0x40
    117.     .EQU __sm_mask=0xB0
    118.     .EQU __sm_powerdown=0x20
    119.     .EQU __sm_powersave=0x30
    120.     .EQU __sm_standby=0xA0
    121.     .EQU __sm_ext_standby=0xB0
    122.     .EQU __sm_adc_noise_red=0x10
    123.     .SET power_ctrl_reg=mcucr
    124.     #endif
    125. #endasm
    126.  
    127. #ifdef _IO_BITS_DEFINITIONS_
    128. #include <mega16_bits.h>
    129. #endif
    130.  
    131. #endif
    132.  
    133.  
    Code ( (Unknown Language)):
    1. delay.h
    2. // CodeVisionAVR C Compiler
    3. // (C) 1998-2000 Pavel Haiduc, HP InfoTech S.R.L.
    4.  
    5. #ifndef _DELAY_INCLUDED_
    6. #define _DELAY_INCLUDED_
    7.  
    8. #pragma used+
    9.  
    10. void delay_us(unsigned int n);
    11. void delay_ms(unsigned int n);
    12.  
    13. #pragma used-
    14.  
    15. #endif
    16.  
     
Loading...