[En-Nut-Discussion] AVR ADC sample fails

Harald Kipp harald.kipp at egnite.de
Tue Jul 7 16:58:09 CEST 2009


Ole Reinhardt wrote:

> Indeed you found a bug :) The intention was to _not_ overwrite memory as
> we (want) to allocate two more words than ADC_BUF_SIZE. But instead we
> just allocate 2 more bytes! The line should be:
> 
> ADC_buffer = NutHeapAlloc(sizeof(uint16_t) * (ADC_BUF_SIZE + 2));

This fixed the problem, NutSleep is working again. Many thanks for
looking into it.


>> Please tell me, that I'm not getting too old for this stuff,
> 
> You are getting too old for this stuff, but you are still young enough
> to find very old bugs :)

My thanks from above are canceled. ;-)

Harald


Off topic:

> But I'd still vote for 
> 
> #define ADC_BUF_TAIL (ADC_BUF_SIZE+1)
> [...]
> buf[ADC_BUF_TAIL] = 0;
> 
> instead of using 
> 
> buf[ADC_BUF_SIZE+1] = 0;

The disadvantage is, that something is hidden. What's the advantage then?






More information about the En-Nut-Discussion mailing list