29TH JULY
My First Program
Using my process of having to "Learn to crawl before you Walk before you Run", I wrote the proverbial "Hello World" program for embedded processors that does nothing more than turn LEDs on and off. The procedure followed is that described in Section 8 (Is Corporal Klinger still wearing a dress?) of the XL_STAR Users Manual but with different code. My program is devoid of any interrupts and just turns LED on and off.
Having the XL_STAR demo program on hand, all I did was to extract the relevant functions and put them into my program. I took this unusual approach so I could get something up and running without needing to know any specfic details of the Freescale MC9S08MM128 microcontroller.
The resultant main() is;
void main(void) { initialise_hardware(); leds_all_off(); leds_all_on(); leds_all_off(); leds_all_on(); for(;;); /* loop forever */ }
This program is designed to be stepped through using the debugger.
Since only functions are called from main(), expedited program stepping can be done pressing the F10 key to "Step Over" on each function to observe the net result of each function.
Note: Depending upon where you locate the imported functions, you may require to declare function prototypes somewhere prior to the main() function.
For my first program I have;
//# Function Prototypes static void initialise_hardware(void); static void configure_LEDs_for_GPIO(void); static void leds_all_on(void); static void leds_all_off(void);
declared before the main() with the imported function code located below main().
If you're wondering why the configure_LEDs_for_GPIO(); declared, it is used by the leds_all_on() and leds_all_off() functions.