ADC not warking Atmega32

General discussion on mikroBasic PRO for AVR.
Post Reply
Author
Message
SPOTLIGHT81
Posts: 9
Joined: 29 Jan 2022 10:25

ADC not warking Atmega32

#1 Post by SPOTLIGHT81 » 19 May 2022 14:39

hi all

In this code, the value of the variable "adcval" does not change
But 1023 remains as you can see in the picture
There is definitely something missing in the code
Please Help
Thank you all

Code: Select all

#include "HC595.h"

unsigned adcval = 0;

void main (void)
{
DDRA.B0 = 0;  /// channel 0 from adc port as input


DDRC.B0 = 1;  /// output for display
DDRC.B1 = 1; /// output for display
DDRC.B2 = 1;  /// output for display

PORTC.B0 = 0;  /// output for display
PORTC.B1 = 0;  /// output for display
PORTC.B2 = 0;  /// output for display

adc_init ();
while (1)
      {
      adcval = adc_read (0);

      Display_HC595 (adcval, 0);
      }
}



Image[/img]

Image[/img]

Image[/img]

ashleyjames0032
Posts: 1
Joined: 20 May 2022 17:48

Re: ADC not warking Atmega32

#2 Post by ashleyjames0032 » 20 May 2022 17:52

Hello, just an idea. Have you thought that maybe the input is equal to the supply voltage of the Atmega ADC? It seems to be full scale value.

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: ADC not warking Atmega32

#3 Post by filip » 27 May 2022 09:00

Hi,

Please take a look at the ADC example from the compiler :
\mikroBasic PRO for AVR\Examples\Development systems\EasyAVR7\ADC on LEDs\

Regards,
Filip.

SPOTLIGHT81
Posts: 9
Joined: 29 Jan 2022 10:25

Re: ADC not warking Atmega32

#4 Post by SPOTLIGHT81 » 14 Jun 2022 23:17

Hello all
Thank you for the reply
Sorry for the late reply, I've been busy the past few days
In fact, I tried the example in the program, but it did not work either

josepvh
Posts: 1
Joined: 07 Sep 2022 18:01

Re: ADC not warking Atmega32

#5 Post by josepvh » 07 Sep 2022 18:12

Hello.

I have the same problem, I found the same example in the help and in the book, with Mikcro Basic and MikroC, it doesn't work, the alue 1023, it stays stable and doesn't change. Can somebody help me

Post Reply

Return to “mikroBasic PRO for AVR General”