Society of Robots - Robot Forum

Software => Software => Topic started by: junior000 on January 25, 2008, 10:37:03 PM

Title: using delays.h of c18 compiler
Post by: junior000 on January 25, 2008, 10:37:03 PM
 i have a problem using the delays.h

  my code goes as follows for blinking an led

 void main()

 {
    TRISC=0b00111111;
     while(1)
     {
        PORTC=0b11000000;//R7 and R6 bits high
        Delay100TCx(200);   //delay
        Delay100TCx(200);
        PORTC=0b00000000;//R7 and R6 low
      }
}

the problem is
1)the program is being executed but the led outputs are alwasys HIGH.
       
Title: Re: using delays.h of c18 compiler
Post by: junior000 on January 25, 2008, 11:19:26 PM
it converts the analog input from port a to digital input for comparision.
the problem in the above program is the statement

  OpenADC(ADC_FOSC_2 & ADC_LEFT_JUST & ADC_1ANA_0REF,  ADC_CH0 & ADC_INT_OFF);//setup adc

the error its showing is "Error [1105] symbol 'ADC_1ANA_0REF' has not been defined"

the output is stored in the registers

      ADRES
      ADRESH
Title: Re: using delays.h of c18 compiler
Post by: rgcustodio on January 25, 2008, 11:39:30 PM
-deleted- (replied to a non-relevant post)
Title: Re: using delays.h of c18 compiler
Post by: junior000 on January 25, 2008, 11:46:21 PM
i checked it...
its included in the ADC.H and i did include it
Title: Re: using delays.h of c18 compiler
Post by: junior000 on January 25, 2008, 11:51:46 PM
it converts the analog input from port a to digital input for comparision.
the problem in the above program is the statement

  OpenADC(ADC_FOSC_2 & ADC_LEFT_JUST & ADC_1ANA_0REF,  ADC_CH0 & ADC_INT_OFF);//setup adc

the error its showing is "Error [1105] symbol 'ADC_1ANA_0REF' has not been defined"

the output is stored in the registers

      ADRES
      ADRESH


sorry this has nothing to do with the post.i have posted it in the wrong topic.
my apologies
Title: Re: using delays.h of c18 compiler
Post by: junior000 on January 25, 2008, 11:53:20 PM
i have a problem using the delays.h

  my code goes as follows for blinking an led

 void main()

 {
    TRISC=0b00111111;
     while(1)
     {
        PORTC=0b11000000;//R7 and R6 bits high
        Delay100TCx(200);   //delay
        Delay100TCx(200);
        PORTC=0b00000000;//R7 and R6 low
      }
}

the problem is
1)the program is being executed but the led outputs are alwasys HIGH.
       
Title: Re: using delays.h of c18 compiler
Post by: hazzer123 on January 26, 2008, 04:37:17 AM
They will seem to be high because you have 2 delays after they have been set high, then no delay when they are set low.

use this code instead -
Code: [Select]
        PORTC=0b11000000;//R7 and R6 bits high
        Delay100TCx(200);   //delay
        PORTC=0b00000000;//R7 and R6 low
        Delay100TCx(200);
Title: Re: using delays.h of c18 compiler
Post by: junior000 on January 26, 2008, 06:04:20 AM
yeah...what a dumb mistake i have made

...thanks anyways