Keil Logo

C166: WORD VARIABLES ON ODD-BYTE BOUNDARIES


Information in this article applies to:

  • C166 All Versions

QUESTION

I am porting a working application from an 8-bit microcontroller to a C16x device. The following code works just fine on the C16x:

#define test MVAR (unsigned short, 0x120000)
test = 100;

However, the following code does not work:

#define test MVAR (unsigned short, 0x120001)
test = 100;

When executing the second example, the program halts. What's going on?

ANSWER

The problem is that the C16x can only access words on word boundaries (even addresses). The C16x devices generate a Class B hardware trap when a word is accessed on an odd address (non-word boundary).

This problem doesn't occur on 8-bit devices because there is no boundary limitations on those parts.

Last Reviewed: Sunday, January 30, 2005


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.