startup code

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

startup code

1,096 Views
AjRj14
Contributor III

Hi,

I have a sample project from AN12086SW software package .

In the startup code , I am having below doubts.

1).  Why system clock is not initialized in startup code?

2). Why interrupts are not disabled while executing the steps in startup code?

Could you please help me understand the above points.

 

Thanks in Advance.

0 Kudos
1 Reply

1,086 Views
lama
NXP TechSupport
NXP TechSupport

Hi,

1) Because Startup code is a default code generated by CW and there are default clock the MCU can work with. You, as an user can change this code anytime you want. The default startup code is used only to copy initialized global variables from flash to RAM, clear/set some memory if required in prm file, setting SP. Of course, the reset vector contains address of the startup code (it is set in prm file)

You do not have to use it if you want to have everything under your control or you think it takes long time. But then you will be responsible for setup of everything. These devices are so simple that if you understand the MCU then everything which has to be done at startup is LDS. (load stack) (Of course then also initialize variables to their initial values by code)

Sometimes it is good to step the startup code to see what is done and how it mirrors your setup from prm file and initialized memories.

So, if this form of the code suits you then it is not necessary to change anything and make setup/changes in main function.

 

2) Because I-bit maskable interrupts are disabled by default. See S12Z CPU manual to understand CCR register.

 

x) I would like to highlight something why it is necessary to understand default startup code. Good example is  watchdog enabled by HW (The watchdog is active immediately after the reset). Then, you have to add processes (refresh of the watch dog) into proper places in the startup code. The default startup code does not know whether you use HW initialized watchdog.

xx) If you, for example, use Processor Expert tool, then you will see that Startup code is omitted and own setup is used. (function CPU setup …. clocks, memory, peripherals,….)

Best regards,

Ladislav

0 Kudos