Keil™, An ARM® Company

Technical Support

CARM: PERIPHERAL REGISTER ACCESS CALLS DABT_HANDLER


Information in this article applies to:

  • CARM All Versions

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

  • Getting Started User's Guide for ARM Powered Microcontrollers

SEE ALSO

Last Reviewed: Tuesday, July 26, 2005


Did this article provide the answer you needed?
 
Yes
No
Not Sure