I'm doing a project in SES writing in C/C++ code for the Atmel SAM3X8E on an arduino due. I'm trying do an ADC in order to read data from an anemometer but i can't get it to work. When I change IDE to IAR the exact same code works perfectly fine, but in SES it doesn't seem to even start en conversion. It get stuck in the while loop since no conversion was completed. The project was started with the SAM3 package. I've tried all sorts of things with the code but nothing seems to work. The code builds and compiles without any errors. I would be really grateful for any help i can get!
Code in SES:
Display All
Code in SES:
C Source Code
- #include <stdio.h>
- #include <stdlib.h>
- #include "SAM3.h"
- unsigned int val = 0;
- void main(void) {
- SystemInit();
- PMC->PMC_PCER0 = 1 << 11; //Enable pheripal clock Port A
- PMC->PMC_PCER1 = 1<<5; //Enable pheripal clock for ADC Controller
- REG_PIOA_PER = 3<<3; //Enable analog pin 5 and 6
- REG_ADC_MR = 1<<9; //Set prescaler rate
- while (1){
- REG_ADC_CHER = 1<<1; //Enable channel register for CH1
- REG_ADC_CR = 1<<1; //Start conversion
- while((REG_ADC_ISR & 1<<1) != 1<<1) //Check end of conversion on CH1
- val = REG_ADC_CDR1; //Get data from Channel Data Register 1
- printf("%d \n", val); //Print value
- }
- }
The post was edited 1 time, last by gustav ().