The TimerISR()
function is defined on line 14. This function is not
used in this simple program but serves as a placeholder for
now. Without defining this interrupt function, the Hi-Tech C
Compiler will detect that the program can start executing
immediately after reset and will not contain the correct reset
vector preventing the bootloader from operating correctly.
Note that keyword is inserted before the function name to
indicate that this is a special function. More on interrupts
later.
The meat of the program (more like a slice of ham in this
simple program) starts on line 26 with the main function void
main( void ) . Functions are to C what subroutines
are to Basic. Functions execute code and are called from
functions and can be passed data and can also return data.
Functions will be expanded on as we develop more programs.
The main
function in C is significant in that normally it is the first
function that is executed after the C startup code is
executed. In the case of a microcontroller running C, there is
a certain amount of code that is executed from reset to
initialize the processor to get it up and running. This
startup code in most cases is hidden from the developer and
basically just does some preliminary initialization. For what
we are learning this isn't important but it's more for your
information.