The task is part of a weather station that we are building for a course that requires it.We do not have access to the libraries that include functions like;AnalogRead(), PinMode(), DigitalWrite() etc so everything has to be done manually by setting bits on every register.

Thanks!Can you tell me what PDC stands for?One more thing I would like to know is the function "AnalogRead" because that's what comes up whenever I try to google. I would be very thankful if you can paste the code of AnalogRead too!

PDC stands for Peripheral DMA Controller. You can find it in the datasheet just like adc stuff: http://www.atmel.com/images/doc11057.pdfAs for reading. Reading ADC_CDR5 should do it. I have done it as well.

Thank you very much for asking something that is answered in the original post.

You're quite welcome.

It was less about asking, as more about confirming your situation. You never explicitly said that using the libraries was forbidden for this class project. You simply stated that they weren't available.

I wanted to be certain that you had these rules to follow, and that you weren't misunderstanding the Arduino platform.

As for helping you, the answers really are in the source and datasheet.

The goal of any class project is to understand something that you yet do not (as is the point of all education). The fine folks here will certainly be happy to help you with specific problems as they arise, but they won't (and shouldn't) do your school work for you.

We have been sitting with it for AT LEAST 10 hours trying to solve it, we asked the mentor 3 times already and there is no one else to ask because we're basically ahead of everyone else. What we received as information to what we are supposed to do in order to read the value is to:

Select/Enable channel with the ADC_CHER registrySet the ADC clock to 14 MHZ with the ADC_MR registryStart a conversion with the ADC_CR registryWait until ADC_SR's DRDY bit is 1Read the converted data with either the ADC_LCDR or the ADC_CDRx register

We've tried a lot of different ways to approach this. We have tried setting the values that the adc_init and adc_config functions sets above in the other post, reading the internal temp sensor, turning on freerun mode.... We have tried so many different variations that I can't even remember all of them.

I am not asking anyone to do our school work for us. I am searching for guidance about exactly which registers we need to change in order to make the ADC work. We are not two stupid guys and are capable enough to understand what the different registers do, once we know which ones we need to use.

You can imagine how frustrated we get when all we get from hours of googling is "use AnalogRead".We only need a small sample of code that is a MUST for using ADC. We obviously need to understand it because we're going to use it for temperature sensors and what not.

We have been sitting with it for AT LEAST 10 hours trying to solve it, we asked the mentor 3 times already and there is no one else to ask because we're basically ahead of everyone else. What we received as information to what we are supposed to do in order to read the value is to:

Select/Enable channel with the ADC_CHER registrySet the ADC clock to 14 MHZ with the ADC_MR registryStart a conversion with the ADC_CR registryWait until ADC_SR's DRDY bit is 1Read the converted data with either the ADC_LCDR or the ADC_CDRx register

We've tried a lot of different ways to approach this. We have tried setting the values that the adc_init and adc_config functions sets above in the other post, reading the internal temp sensor, turning on freerun mode.... We have tried so many different variations that I can't even remember all of them.

I am not asking anyone to do our school work for us. I am searching for guidance about exactly which registers we need to change in order to make the ADC work. We are not two stupid guys and are capable enough to understand what the different registers do, once we know which ones we need to use.

You can imagine how frustrated we get when all we get from hours of googling is "use AnalogRead".We only need a small sample of code that is a MUST for using ADC. We obviously need to understand it because we're going to use it for temperature sensors and what not.

This is the adc sampling code I use for my USB Audio Interface. It actually contains everything for reading ADC values.

Indeed the datasheet is pretty good - but its a complex beast and you will need to read the ADC section of the datasheet carefully 2 or 3 times (there is no magicroute to understanding a complex machine)

If its any consolation the ARM processors are as complex asmainframe computers of the 60's and 70's, and they came with a wholepallet full of manuals!

4x is the value that varies between each reading. It's often sitting at 40, 41, 43 and sometimes at 38 or 39. It appears to be random but there is a slight limit to it, it rarely changes from a big value to a small value, i.e. from 43 to 38 or vice versa. It does , however, change by up to ~10 if we press a button on our keypad.

The output is the same if we have the photo sensor plugger in or not.

It's connected like this:VCC -------- R -------PIN---------LDR--------GROUNDNote: R is connected to LDR and PIN is connected between them.

I suspect we need to edit more bits in the ADC_MR register before we can get this right.

Problem is, we have no idea how a high/low SETTLING time (amongst others) affect the ADC.