ADC configuration in ATMEL ARM SAM E70 BOARD

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


Hello everyone, I want to operate adc on ATSAME70 development board. I have programmed the afec and in the code I have set the afec clock of 10Mhz because my board crystal oscillator is of 12Mhz . According to that if I give a sine wave of say 300Khz to my afec from the function generator it should work fine to get a digitized output. But I am getting an output as below, only for these are for frequencies 1K,5K,8K,10K . On 1 and 10K I am getting perfect output but not on 5k and 8k.On 300K there is too much of distortion And also my output should be in step voltage form meaning digitized form please check to it..This is the code. Please help me out !!!

 

#include "board.h"

#include <stdbool.h>

#include <stdio.h>

#include "afec.h"



#define IRQ_PRIOR_PIO 0

#define TEST_CHANNEL 0

#define AFE_CLK 10000000

#define CHANNEL_OFFSET 0X200 /*DAC OFFSET */



static void afe_initialization(void)

{

AFEC_Initialize( AFEC0,ID_AFEC0 );


/* AFEC MODE REGISTER CONFIGURATION */

AFEC_SetModeReg(AFEC0,AFEC_MR_FREERUN_OFF|AFEC_MR_TRANSFER(1)|AFEC_MR_TRACKTIM(2)| AFEC_MR_ONE| AFEC_MR_STARTUP_SUT64);


/* Set AFEC clock */

AFEC_SetClock(AFEC0, AFE_CLK, BOARD_MCK);


/* Select the channel */

AFEC_EnableChannel(AFEC0, TEST_CHANNEL);


/* Adjusting the channel level offset */

AFEC_SetAnalogOffset(AFEC0,TEST_CHANNEL,CHANNEL_OFFSET);


/* Enable the PGA0 and PGA 1 by tuning the AFE Bias Current Control */

AFEC_SetAnalogControl(AFEC0, AFEC_ACR_IBCTL(1) | AFEC_ACR_PGA0_ON | AFEC_ACR_PGA1_ON);


/* Configuring the Extended Mode Register */

AFEC_SetExtModeReg(AFEC0,0| AFEC_EMR_RES(256)| AFEC_EMR_TAG | AFEC_EMR_STM );

}


extern int main( void )

{


/* Disable watchdog */

WDT_Disable(WDT);

                                                                                                                                                                                           

while(1){

afe_initialization();

AFEC_StartConversion(AFEC0);

while (!(AFEC_GetStatus(AFEC0) & AFEC_ISR_EOC0));


    char ch =  (AFEC_GetLastConvertedData(AFEC0) & AFEC_LCDR_CHNB_Msk ) >> AFEC_LCDR_CHNB_Pos;

float voltage = ((AFEC_GetLastConvertedData(AFEC0) & AFEC_LCDR_LDATA_Msk));

printf("%02u %04u\n\r" ,(unsigned int)ch,(unsigned int)voltage);


     


}

}

 




 

avantika

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It's not clear how the graphs relate to your program. Obviously you can't expect the printf to keep up with a useful sample rate. So sample to memory a while and printf after if you are not doing this already.

/Lars