SAMD11 xPlained Light Sensor demo bugs

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

I can't find the bug reporting mechanism anymore, but just for others who may run into this there are two bugs in the Light Sensor demo:

1. I am not using the IO1 board, just a proto board so maybe that is the problem. But in the Configuration section the input is set to Ain2 instead of Ain0. So all I get is random numbers. To fix, just go into "Re-Configure Atmel Start Project, drop down the IO1 Light Sensor block (really an ADC block) go down to the bottom where it says Positive Mux Input Selection and select ADC_AIN0_pin

2. Moving average readings around 3% low. Data in the buffer is OK except last sample is always zero. Looks like an off-by-one in the Main.c that makes it not sample the last data point before launching the result reporting 

Line 124 in main.c, timer callback

void timer_cb(const struct timer_task *const timer_task)
{
	fired_count += CONF_ADC_BYTES;

	if (CONF_ADC_BYTES == fired_count) {
		state = APP_STATE_WAITING_FOR_COLLECT_STR_TX;
		io_write(io, collect_str, sizeof(collect_str) - 1);

	} else if (fired_count == MAX_TIMER_FIRE_AMOUNT) {
		uint8_t i = 0;

		fired_count       = 0;

The timer fires, fixed_count is updated but the last conversion is not done. Not necessary to my project to fix this, I won't be using a goofy moving average in my code, but it is a bug that could be a puzzle to someone else.