SAMC21 Xplained read ADC values

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

Hello,

 

I did the Tutorial from Atmel ("Atmel START Sensors: ADC with Delay, Visualization (#5)") but I read all the time FF form the pin PB07. I use the same configuration from the atmel guy. Can somebody help please?

 

Here is my code:

 

#include <atmel_start.h>

struct io_descriptor *usart_edbg_io; 
volatile bool conversion_done = false; 
uint8_t ADC_result[2]; 
int conversion_result; 

static void convert_cb_ADC(const struct adc_async_descriptor *const descr, const uint8_t channel)
{
	conversion_done = true;
}

void ADC_light_init(void)
{
	adc_async_register_callback(&ADC_0, 0, ADC_ASYNC_CONVERT_CB, convert_cb_ADC);
	adc_async_enable_channel(&ADC_0, 0);
	adc_async_start_conversion(&ADC_0);
}

void USART_EDBG_init(void)
{
	usart_sync_get_io_descriptor(&USART_0, &usart_edbg_io);
	usart_sync_enable(&USART_0);	
}

int main(void)
{
	/* Initializes MCU, drivers and middleware */
	atmel_start_init();
	USART_EDBG_init(); 
	io_write(usart_edbg_io, (uint8_t *)"Clocks & UART ready!\n", 21);
	ADC_light_init(); 
	io_write(usart_edbg_io, (uint8_t *)"ADC ready!\n", 11);
	/* Replace with your application code */
	while (1) {
		delay_ms(500); 
		adc_async_start_conversion(&ADC_0); 
		while(!conversion_done){}; 
		adc_async_read_channel(&ADC_0, 0, ADC_result,1);
		conversion_result = ADC_result[0]*256; 
		//io_write(usart_edbg_io, &ADC_result, 1);
	}
}

 

Last Edited: Fri. Oct 2, 2020 - 11:09 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I solved that problem by myself. Adding ADC_result [0] and ADC_result[1] to a 16bit value. Beginner fail^^