[En-Nut-Discussion] NutGetMillis is a _very expensive_ function on Ethernut3

duane ellis ethernut at duaneellis.com
Wed Aug 20 13:44:58 CEST 2008


Harald Kipp wrote:

 >> IMHO, using an array instead of a structure will be more flexible. 
This way we can define different indices for different targets.

I do not think the ARRAY should be public, it should be 100% hidden 
"static to a chip/target specific C file", and the C file should 
implement access functions to get the clock values. Data Hiding is 
good.  How that C file/function does its job internally is up to the 
implementor.

> Right now we have no more than 2 clocks, which are typically all used.

Today you say 2 clocks - the Atmel SAM series can select any of 4 
different clocks, then divide those
     Slow clock (32khz),  main-osc (typically 18.432mhz), PLLA, or PLLB..

Hence - at least 4 access functions.

But that is not all - I would expect 2 more functions, total 6.

(A) the currently selected CPU clock, - as defined by the selected 
PRESCALE value

Example the PLL runs at 180mhz on sam9
The PLL runs at 96mhz on SAM7
The AT91SAM9 - cpu runs at the PLL frequency of 180mhz
The SAM7 - uses DIV-2 from the PLL thus 48mhz

(B) The currently selected MCLK that all perphials are using (ie: input 
to the UART block for baud clock) - as defined by its separate prescale 
value.

Example the AT91RM9200 - bus clock is I think 1/3 of that - or 60mhz.
I'm not sure about the AT91SAM9 series - I think it is  DIV 1/2/4 of the 
CPU clock.
The SAM7 - I think uses DIV1..

Depends on how much battery you want to burn up, or if you are on a battery.

-Duane.




More information about the En-Nut-Discussion mailing list