« Return to Thread: AVR ADC sample fails

Re: AVR ADC sample fails

by Ethernut :: Rate this Message:

Reply to Author | View in Thread

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?



_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

 « Return to Thread: AVR ADC sample fails