change reset vector function

cancel
Showing results for 
Search instead for 
Did you mean: 

change reset vector function

872 Views
LiveMike
Contributor II

CW6.1

brand new project in "C"

open .prm file and change reset vector to:

"VECTOR 0 _Entry" instead of "VECTOR 0 _Startup"

i delete the Start08.c file all together.

in main.c i add the function "void _Entry(void){/*do stuff*/}"

when i MAKE the project i get the error:

"Link Error: L1115 Function _Startup not found"

 

WHY is it still looking for "_Startup" and not "_Entry" ???

 

-Mike

Labels (1)
Tags (1)
4 Replies

106 Views
BlackNight
NXP Employee
NXP Employee

Hello,

 

INIT _Entry

 

to your linker . prm file.

See 'User-Defined Startup Routines" in the Build_Tools_Utiliites.pdf

 

Hope this helps,

BK

0 Kudos

106 Views
LiveMike
Contributor II

Thanks BK.

 

I have so many questions though.  We have been using Assembly for decades, and now are switching to C.  Not fun.  In Assembly, we had one file, main.asm.  Initialization, decalration of registers, the main loop, subroutines, and vectors.  There was a .prm linker file, and that's it.  I feel like in C there are so many "extra" files, and NOTHING is organized.  I want to use C but I feel like I don't know where to start.  I don't understand the #pragma at all, I know it's for the compiler, but Assembly wasn't anywhere near this complicated.  If I create a new blank "C" project, where do I define my "registers"?  How do I make them 8 bit registers?  What is the equivalent of "ORG" statements?  I'm still trying to figure out "global" variables in C and header files etc.  (By the way, it's not the C language, it's the application of it.)  Do you have some links or references that explain the basics for beginners?  And I know most will say, stop trying to "edit" everything, just create your program in "main".  The problem is I can't ship out devices without knowing what exactly every line of code does.  Thanks again.

 

-Mike

0 Kudos

106 Views
bigmac
Specialist III

Hello Mike,

 

When you created a new project using the wizard, you are provided with a basic framework for the file main.c, which incorporates the function main().  This function is equivalent to the initialisation sequence, followed by a non-exiting loop that you would also have in an assembly project.  Within the file Start08.c is the _Startup() function that is normally referenced by the reset vector, and this will exit by doing a direct jump to main(). 

 

_Startup() basically does two things.  It provides "copydown" of initialisation values for global and static variables, and it initialises the stack pointer.  When you create a new project, you are given the choice of either ANSI initialisation, or minimal initialisation.  With the latter selection, the copydown process is eliminated, leaving only the initialisation of the stack pointer prior to jumping to main().  It is not a good idea to bypass the initialisation of the stack pointer.

 

You will notice that the top of file main.c there is an #include derivative.h.  This file, in turn, #includes the actual header file for the MCU derivative that you are using, and this is already incorporated within the project structure.  This identifies all the MCU register names, and their associated individual bits.  derivative.h should be #included at the top of any other .c file that manipulates MCU registers.

 

The MCU header file contains many examples where, obviously, a particular register needs to be associated with a specific address.  It is also possible for the linker to place a function at a specific address if a special segment is created for that function (see documentation for .PRM file).

 

I have attached some basic C tutorial information obtained from the web some time ago.  Google will probably find numerous other examples.  There is also the publication "HCS08 Unleashed' by Fabio Pereira, that contains a multitude of programming examples in C, and directly relates to an earlier version of CodeWarrior.

 

Regards,

Mac

 

106 Views
LiveMike
Contributor II

WOW bigmac!

 

Thank you, very informative and educational, and easy to understand.  I've been programming java, htlm, xml, css, javascript, php, blah blah blah forever (10 years lol) but this microcontoller stuff seems MORE complex, haha.  thanks for the attachemnts and i'll deff look into that "HCS08 unleashed" publication.

 

thanks again

 

-mike

0 Kudos