EmbDev.net

Forum: ARM programming with GCC/GNU tools Cstartup_SAM7.c LowLevelInit


Author: Tibo Tibo (tibo)
Posted on:

Rate this post
0 useful
not useful
Hi there!

I have a quetion about the file in subject.
There is two parts
-------------------------------------------------------------------
//* Set MCK at 48 054 850
// 1 Enabling the Main Oscillator:
// SCK = 1/32768 = 30.51 uSecond
// Start up time = 8 * 6 / SCK = 56 * 30.51 = 1,46484375 ms
// mthomas-avoid warning pPMC->PMC_MOR = (( AT91C_CKGR_OSCOUNT & (0x06
<<8) | AT91C_CKGR_MOSCEN ));
   pPMC->PMC_MOR = ( (( AT91C_CKGR_OSCOUNT & (0x06 <<8)) |
AT91C_CKGR_MOSCEN ));
-------------------------------------------------------------------
Where is the 32768Hz from? In datasheet there is typ 32000Hz, so why
specifically 32.768kHz?

------------------------------------------------------------------------ 
-------
// Wait the startup time
   while(!(pPMC->PMC_SR & AT91C_PMC_MOSCS));
// 2 Checking the Main Oscillator Frequency (Optional)
// 3 Setting PLL and divider:
// - div by 14 Fin = 1.3165 =(18,432 / 14)
// - Mul 72+1: Fout =  96.1097 =(3,6864 *73)
// for 96 MHz the erroe is 0.11%
// Field out NOT USED = 0
// PLLCOUNT pll startup time estimate at : 0.844 ms
// PLLCOUNT 28 = 0.000844 /(1/32768)
   pPMC->PMC_PLLR = ((AT91C_CKGR_DIV & 14 ) |
                     (AT91C_CKGR_PLLCOUNT & (28<<8)) |
                     (AT91C_CKGR_MUL & (72<<16)));
------------------------------------------------------------------------ 
--------
In this part, I found 73HEX=115decimal then I found 151405665Hz so more
than 151MHz instead of 96 wich is a difference.

So I'm wondering how it works. Am I wrong somewhere? If I'm right how
does it work anyway?

Maybe it is not important (sorry) but when I don't get it, I can't use
it (psycological problem from me). And I'm actually trying to manage AD
Conversion so I need to understand Clock working.
Does anyone have an idea, e.g. Martin Thomas?

Thanks a lot
Tibo

Author: Tibo Tibo (tibo)
Posted on:

Rate this post
0 useful
not useful
Tibo Tibo wrote:
> // for 96 MHz the erroe is 0.11%

> // PLLCOUNT pll startup time estimate at : 0.844 ms
> // PLLCOUNT 28 = 0.000844 /(1/32768)

Another little thing, please, how do you estimate this 844µs for startup
time? And where the 0.11% is from?

Thanks
Tibo

Author: Martin Thomas (mthomas) (Moderator)
Posted on:

Rate this post
0 useful
not useful
The lowlevel-init code use in some of the WinARM test-examples is
basically just a copy of Atmel code for other toolsets/chains which I
found on at91.com/tools/kits before they "optimized" the at91.com-site.
There have been several versions in various examples.

The latest "official" (=published by Atmel) versions should be available
in the Software-pacakges from
http://www.atmel.com/dyn/products/tools_card.asp?t... . Also
check http://www.atmel.com/dyn/resources/prod_documents/...

Author: Tibo Tibo (tibo)
Posted on:

Rate this post
0 useful
not useful
Martin Thomas wrote:
> The lowlevel-init code use in some of the WinARM test-examples is
> basically just a copy of Atmel code for other toolsets/chains which I
> found on at91.com/tools/kits before they "optimized" the at91.com-site.
> There have been several versions in various examples.
>
> The latest "official" (=published by Atmel) versions should be available
> in the Software-pacakges from
> http://www.atmel.com/dyn/products/tools_card.asp?t... . Also
> check http://www.atmel.com/dyn/resources/prod_documents/...

Thank you, the way of getting 48MHz is still a bit strange but I'll go
in further investigation about this.

Have a nice day
Tibo

Author: Tibo Tibo (tibo)
Posted on:

Rate this post
0 useful
not useful
Tibo Tibo wrote:
> Martin Thomas wrote:
>> The lowlevel-init code use in some of the WinARM test-examples is
>> basically just a copy of Atmel code for other toolsets/chains which I
>> found on at91.com/tools/kits before they "optimized" the at91.com-site.
>> There have been several versions in various examples.
>>
>> The latest "official" (=published by Atmel) versions should be available
>> in the Software-pacakges from
>> http://www.atmel.com/dyn/products/tools_card.asp?t... . Also
>> check http://www.atmel.com/dyn/resources/prod_documents/...
>
> Thank you, the way of getting 48MHz is still a bit strange but I'll go
> in further investigation about this.
>
> Have a nice day
> Tibo

There is no mistake, sorry! Values in C code are in decimal and not in
Hexa.

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.