element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Personal Blogs
  • Community Hub
  • More
Personal Blogs
Very Compact's Blog VY Canis Majoris Part 07
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: COMPACT
  • Date Created: 25 Mar 2017 10:29 PM Date Created
  • Views 329 views
  • Likes 2 likes
  • Comments 0 comments
  • xl_star
Related
Recommended

VY Canis Majoris Part 07

COMPACT
COMPACT
25 Mar 2017

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.

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube