ADC configuration in ATMEL ARM SAM E70

1 post / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


Hello everyone following is the code which works for analog front end controller(afec) module in same70 xpld board. now this afec module has adc and dac both in its internal architecture. I just run the sample code for afec module which is given. I am giving sine wave at input for 400khz offset 500mv problem is that I am not getting digitized output and getting the same sine wave as this has adc and dac both the output I'm getting is from dac, but I want output from adc only what to do pls suggest. How to seperate my adc and dac both programming point of view . pls check the attached user manual too of afec

 

 

#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



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))*3254/4096;

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

    

    

    }

}

 

Attachment(s): 

avantika