c - ADC_READ for PIC - Stack Overflow

I made a code using ADC_Read function in MikroC PRO IDE, but the code doesn't build, and the follo

I made a code using ADC_Read function in MikroC PRO IDE, but the code doesn't build, and the following error message appears:

the variable ADC_Read isn't declared

I'm using a PIC12F675 with an oscillator "internal RC no clock"

#define D1 GPIO.F1
#define D2 GPIO.F2
#define D3 GPIO.F4
#define D4 GPIO.F5

int leitura = 0;

void main()
{
  ANSEL = 1;  // 0b00000001   AN0 is analog
  ADCON0 = 1; // Select the AN0 Output
  CMCON = 7;

  TRISIO = 1; //GPIO.F0 seja uma entrada
  GPIO = 0;   //Inicia tudo em low

  while(1)
  {
    leitura = ADC_Read(0);

    if(leitura > 0)
    {
      D1 = 0;
      D2 = 0;
      D3 = 0;
      D4 = 0;
    }
    if(leitura > 204)
    {
      D1 = 1;
      D2 = 0;
      D3 = 0;
      D4 = 0;
    }
    if(leitura > 408)
    {
      D1 = 1;
      D2 = 1;
      D3 = 0;
      D4 = 0;
    }
    if(leitura > 612)
    {
      D1 = 1;
      D2 = 1;
      D3 = 1;
      D4 = 0;
    }
    if(leitura > 816)
    {
      D1 = 1;
      D2 = 1;
      D3 = 1;
      D4 = 1;
    }

     delay_ms(100); //taxa de atualização do ADC
  } //end while

} //end main

someone can help me?

I made a code using ADC_Read function in MikroC PRO IDE, but the code doesn't build, and the following error message appears:

the variable ADC_Read isn't declared

I'm using a PIC12F675 with an oscillator "internal RC no clock"

#define D1 GPIO.F1
#define D2 GPIO.F2
#define D3 GPIO.F4
#define D4 GPIO.F5

int leitura = 0;

void main()
{
  ANSEL = 1;  // 0b00000001   AN0 is analog
  ADCON0 = 1; // Select the AN0 Output
  CMCON = 7;

  TRISIO = 1; //GPIO.F0 seja uma entrada
  GPIO = 0;   //Inicia tudo em low

  while(1)
  {
    leitura = ADC_Read(0);

    if(leitura > 0)
    {
      D1 = 0;
      D2 = 0;
      D3 = 0;
      D4 = 0;
    }
    if(leitura > 204)
    {
      D1 = 1;
      D2 = 0;
      D3 = 0;
      D4 = 0;
    }
    if(leitura > 408)
    {
      D1 = 1;
      D2 = 1;
      D3 = 0;
      D4 = 0;
    }
    if(leitura > 612)
    {
      D1 = 1;
      D2 = 1;
      D3 = 1;
      D4 = 0;
    }
    if(leitura > 816)
    {
      D1 = 1;
      D2 = 1;
      D3 = 1;
      D4 = 1;
    }

     delay_ms(100); //taxa de atualização do ADC
  } //end while

} //end main

someone can help me?

Share Improve this question edited Mar 28 at 13:34 President James K. Polk 42k29 gold badges109 silver badges145 bronze badges asked Mar 27 at 13:17 Gustavo motaGustavo mota 696 bronze badges 5
  • 1 What do you mean by "does not work"? What do you expect and what happens instead? – the busybee Commented Mar 27 at 14:40
  • 1 @thebusybee the code doesn't build, and an error mensage appears "the variable ADC_Read doesn't declared" – Gustavo mota Commented Mar 28 at 12:07
  • Please edit your question to clarify, comments are not for this. This site is not a forum. – the busybee Commented Mar 28 at 12:18
  • Include the relevant header. – Lundin Commented Mar 28 at 13:31
  • 1 @Lundin I thought that too, but it looks like MikroC PRO IDE doesn't require based on the examples – pm101 Commented Mar 28 at 14:59
Add a comment  | 

1 Answer 1

Reset to default 1

By searching the MicroC PRO IDE forums, it seems to you need to enable the ADC option under the "Library Manager". Does this solve your problem?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744086415a4556262.html

相关推荐

  • c - ADC_READ for PIC - Stack Overflow

    I made a code using ADC_Read function in MikroC PRO IDE, but the code doesn't build, and the follo

    17天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信