Skip to main content
aialinux
Associate III
July 24, 2006
Question

ADC12 problem

  • July 24, 2006
  • 8 replies
  • 1505 views
Posted on July 24, 2006 at 14:45

ADC12 problem

This topic has been closed for replies.

8 replies

aialinux
aialinuxAuthor
Associate III
March 19, 2006
Posted on March 19, 2006 at 21:22

I am using STR710 ADC12.The program as below:

ADC12_ChannelSelect(ADC12_CHANNEL0);

/* Start the Converter */

ADC12_ConversionStart();

/* Wait until the availabiliy of data in the specific flags */

while (ADC12_FlagStatus (ADC12_DA0)==RESET);

/* Get the conversion result from the correponding Data register */

ADC_Reg = ADC12_ConversionValue(ADC12_CHANNEL0);

But the program can't run out of : while (ADC12_FlagStatus (ADC12_DA0)==RESET);

aialinux
aialinuxAuthor
Associate III
March 22, 2006
Posted on March 22, 2006 at 21:24

Yes! The problem is still the same.

It can't run out of : while (ADC12_FlagStatus (ADC12_DA0)==RESET);

ezanen9
Associate III
March 27, 2006
Posted on March 27, 2006 at 05:54

Hi,

Just a suggestion: did you set the ADC_en bit in the PCU_BOOTCR register?

If not the ADC will not run and the sample ready flag not set.

Regards,

Jimmey

gawied
Associate II
July 19, 2006
Posted on July 19, 2006 at 09:05

Hi Dom

Did you solve the ADC12 problem? If so please let me know what was wrong, as I am getting the same problem - not every time though, which makes it even more scary ;-).

Cheers

Gawie

gawied
Associate II
July 21, 2006
Posted on July 21, 2006 at 05:46

Hi

I solve my problem, but I am not quite sure of my solution. Maybe somebody can shed some light on the issue.

On startup I did initialise the ADC by calling the following functions:

// Configure the used analog input to HI_AIN

GPIO_Config (GPIO1, 0x0001, GPIO_HI_AIN_TRI);

// Initialize the conveter register.

ADC12_Init();

// Configure the ADC prescaler to have a sampling frequency = 500Hz

ADC12_PrescalerConfig(500);

// Select the conversion mode=single channel

ADC12_ModeConfig (ADC12_SINGLE);

And when ever I want to get an ADC value I did a few (100 or so) conversions and then calculated the average. I called the functions as follow:

// Select the channel to be converted

ADC12_ChannelSelect(ADC12_CHANNEL0);

// Start the Converter

ADC12_ConversionStart();

// Wait until the availabiliy of data in the specific flags

while (!ADC12_FlagStatus (ADC12_DA0));

// Get the conversion result from the corresponding Data register

ADC_Reg = ADC12_ConversionValue(ADC12_CHANNEL0);

My problem was that the flag, indicating that the conversion was completed, was not set on some occasions.

I fixed it by doing the init routines not just at startup, but also every time I wanted to do an ADC conversion. Does this make sense and do I have to init the ADC before every conversion?

Any comment would help ;-).

Thanks,

Gawie

hichem2
Associate
July 21, 2006
Posted on July 21, 2006 at 13:01

Hello,

Normally you don't need to initialize the ADC before every conversion, please could you tell me wich library version you are using and check the

ADC12_Init(); funtion body .

cheers,

Hich

gawied
Associate II
July 21, 2006
Posted on July 21, 2006 at 18:11

Hi

I am using libary ver 3.1 and the ADC12_Init() looks like follows:

void ADC12_Init(void)

{

/* Initiate ADC12 registers to their reset values */

ADC12->CSR = 0x0000;

ADC12->CPR = 0x0005;

}

Cheers

Gawie

gawied
Associate II
July 24, 2006
Posted on July 24, 2006 at 14:45

Ok, I solved my problem!

I had more than one channel selected in ADC12->CSR while I was using the ADC in single conversion mode and that was the cause why the completion flag was never set.

Cheers

Gawie