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 08
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: COMPACT
  • Date Created: 28 Mar 2017 9:23 PM Date Created
  • Views 326 views
  • Likes 1 like
  • Comments 0 comments
  • xl_star
Related
Recommended

VY Canis Majoris Part 08

COMPACT
COMPACT
28 Mar 2017

31ST JULY

Crawling about

With the preliminary shakedown tests out of the way it was now time to delve into the detail.

I spent bits of today learning about the ins and outs of the CodeWarrior IDE, its C compiler and freescale MC9S08MM128.

I learned a few interesting things that might be of interest to all. Here they are;

 

1. MC9S08MM128 bit fields

The MC9S08MM128.h files contains structures and explicit definitions to support bit fields for some of the MC9S08MM128 registers.

These are quite useful but there is at least one caveat to their use. See the next item about optimisations for details.

These definitions allows direct reference to a specific register bits.

e.g.

PTAD_PTAD4 = 0;     // Turn "14-bit data" Green LED on

 

2. Optimisations

By default some optimisations are on and have some unwanted side effects.

My general rule is to turn all optimisations off until your program is fully working and work on optimisations afterwards.

 

     // Standard method - works with default optimisations
     PTAD = 0xFF;
     PTAD = ~(0x01<<4);
     PTAD = 0xFF;
     PTAD = ~(0x01<<4);

     // Bit field method - requires default optimisations off
     PTAD_PTAD4 = 1;
     PTAD_PTAD4 = ~PTAD_PTAD4;
     PTAD_PTAD4 = ~PTAD_PTAD4;
     PTAD_PTAD4 = ~PTAD_PTAD4;


3. Interrupt vectors - ANSI style

The XL_STAR demo program does not specify the interrupt vector for an ISR in the C code file.

 

     interrupt void button_press_isr (void)
     interrupt void accelerometer_isr (void)

 

So how is it done? image

imageIt is done with explicit entries in the projects link  .prm file with additional entries.

This requires altering the .prm file to specify the required vector for ISR declarations.

 

     VECTOR 27 button_press_isr      /* KBI1 keyboard pins from push buttons SW1 - SW3 */
     VECTOR 28 accelerometer_isr     /* KBI2 keyboard pins from MMA_INT1/2 outputs accelerometer */

 

I prefer to have the vector specified in the source code and not touch any external files such as .prm files unless absolutely necessary.

For this technique it is best done with the associated constant (from the device header file).

 

     interrupt void VectorNumber_Vkeyboard1 button_press_isr (void)
     interrupt void VectorNumber_Vkeyboard2 accelerometer_isr (void)

  • 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