ARM Technical Support Knowledge Articles

PERIPHERAL REGISTER ACCESS CALLS DABT_HANDLER

Applies to: CARM C Compiler

Answer


Information in this article applies to:


QUESTION

I am using existing code for the I2C interface for a Philips LPC2000 device. However, when I executed the following function, my software jumps to the Data Abort Handler (DAbt_Handler). What can be wrong?

#include "LPC22xx.h"

#define REG(addr) (*(volatile unsigned long *)(addr))

void InitialiseI2C (void) {
  REG(I2C_I2CONCLR) = 0xFF;
  REG(PINSEL0)      = 0x50;       //  Set output pin SCL and SDA
  REG(I2C_I2CONSET) = 0x40;
  REG(I2C_I2CONSET) = 0x64;
  REG(I2C_I2DAT) = 0x42;
  REG(I2C_I2CONCLR) = 0x08;
  REG(I2C_I2CONCLR) = 0x20;
}

ANSWER

You need to remove the REG() macros in your source code, since the pointer construct is already part of the register definition file LPC22xx.h that is provided with the Keil CARM Compiler.

Instead of REG(I2C_I2CONCLR) just use I2C_I2CONCLR.

Example:

void InitialiseI2C (void) {
  I2C_I2CONCLR = 0xFF;
  PINSEL0      = 0x50;       //  Set output pin SCL and SDA
  I2C_I2CONSET = 0x40;
  I2C_I2CONSET = 0x64;
  I2C_I2DAT)   = 0x42;
  I2C_I2CONCLR = 0x08;
  I2C_I2CONCLR = 0x20;
}

MORE INFORMATION

SEE ALSO

Article last edited on: 2005-07-26 05:43:47

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