ARM Technical Support Knowledge Articles

WORD VARIABLES ON ODD-BYTE BOUNDARIES

Applies to: C166 C Compiler

Answer


Information in this article applies to:


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.

Article last edited on: 2005-01-30 14:17:05

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential