Cstartup_SAM7.c LowLevelInit

OP #1173793
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
OP #1173794
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
Moderator #1173795
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?tool_id=4227 . Also
check http://www.atmel.com/dyn/resources/prod_documents/AT91SAM_pll.htm
OP #1173796
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?tool_id=4227 . Also
> check http://www.atmel.com/dyn/resources/prod_documents/AT91SAM_pll.htm

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
OP #1173797
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?tool_id=4227 . Also
>> check http://www.atmel.com/dyn/resources/prod_documents/AT91SAM_pll.htm
>
> 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

A question of your own? This thread is over 18 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.