nikhil_jain
Member level 4
- Joined
- Sep 20, 2010
- Messages
- 76
- Helped
- 37
- Reputation
- 76
- Reaction score
- 36
- Trophy points
- 1,308
- Location
- India
- Activity points
- 1,622
Hi
I'm trying to work with ADC for the ARM controller on the new Arduino Due board, but no success so far. Has anyone done this already?
This is my code:
I'm using Atmel Software Framework (ASF) in Atmel Studio.
Thanks
I'm trying to work with ADC for the ARM controller on the new Arduino Due board, but no success so far. Has anyone done this already?
This is my code:
Code:
void ADC_IrqHandler(void);
void adc_setup(void);
#define PIOC_Set_Output *((uint32_t volatile *)0x400E1230) //PIO_SODR
#include <asf.h>
//ADC Interrupt handler
void ADC_IrqHandler(void)
{
// Check the ADC conversion status
if ((adc_get_status(ADC) & ADC_ISR_DRDY) == ADC_ISR_DRDY)
{
uint32_t result = adc_get_latest_value(ADC);
PIOC_Set_Output = result;
}
}
void adc_setup(void)
{
adc_init(ADC, sysclk_get_main_hz(), sysclk_get_main_hz()/4, 8); //ADC_CLOCK = master_clock/4
adc_configure_timing(ADC, 0, ADC_SETTLING_TIME_3, 1);
adc_set_resolution(ADC, ADC_MR_LOWRES_BITS_12);
adc_enable_channel(ADC, ADC_CHANNEL_5);
adc_enable_interrupt(ADC, ADC_IER_DRDY);
adc_configure_trigger(ADC, ADC_TRIG_SW, 0);
}
int main (void)
{
board_init();
sysclk_init();
adc_setup();
volatile uint8_t count = 0;
while(1)
{
adc_start(ADC);
count++;
}
}
I'm using Atmel Software Framework (ASF) in Atmel Studio.
Thanks