[En-Nut-Discussion] Some Nut OS bugs???
Ashley Duncan
ashes.man at gmail.com
Mon Sep 25 22:56:54 CEST 2006
Hi all,
I have been doing a little mucking round with Nut OS and have come up
with the following notes... They appear to be bugs, but I havn't put weeks
of thought into them, will leave it to the people to decide.
1 - In the heap deallocate function the available space variable is
increased at the start (as we are freeing up that memory). If the memory
was already free, the function returns arfter freeing no memory but the
available space variable has still grown.
2 - In allocate routine ... we check if there is enough available space,
then we increase the space required for the block we are going to allocate.
Is there still enough free space?
3 - OCR_VALUE defines the timer 0 compare value ... is the macro correct?
Does the ms counter (ticks) add 8 us to each count? meaning we add 1ms for
every 125ms?
#define OCR_VALUE ((2 * TIMER_CRYSTAL / (TIMER_PRESCALE * TICK_NFREQ)
+ 1) / 2)
if:
TIMER_CRYSTAL = 16000000
TIMER_PRESCALE = 128
TICK_NFREQ = 1000
then...
(32000000 / 128000 + 1) / 2 = 125.5 ... but should be 124 compare value
>From data sheet:
foc = fclk / (2 x pre x (1 + OCP))
2 x foc x pre = fclk / (1 + OCP)
OCP = (fclk / (2 x foc x pre)) - 1
= (16000000 / (2 x 500 x 128)) - 1 // Remember we want 500 Hz to
get one interrupt each ms
= 124
Macro should read:
#define OCR_VALUE ((TIMER_CRYSTAL / (2 * (TICK_NFREQ / 2) *
TIMER_PRESCALE)) - 1)
I didn't check the tick frequency calculation...
Thanks for reading this far!
Ashley Duncan
More information about the En-Nut-Discussion
mailing list