Need help starting out with NXP LPC1114 coding

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Need help starting out with NXP LPC1114 coding

444 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by AdrianYong on Sun Aug 12 23:36:54 MST 2012
Hey guys,

I do know C programming but I am new to microcontroller programming.

Firstly, I notice that I cannot find information about coding from data sheet of the LPC1114. The datasheet does describe the registers but not their "names" in the compiler.

where do I get information regarding the "names/pointers" as shown below and ways of accessing other functions?

LPC_12C->STAT
LPC_12C->CONCLR
LPC_12C->CONSET
LPC_IOCON
LPC_SYSCON
0 Kudos
4 Replies

394 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by frame on Tue Aug 14 11:39:13 MST 2012
Having turned to develop SW for microcontrollers just recently (i.e. a few years ago), I understand the confusion behind this question.

In C/C++ coding for a 'real' OS, fixed addresses are almost taboo. Interrupts are hidden in the OS, "while (1)" loops are virtually unknown,
and there are plenty of comfortable library functions.

To the things you mentioned:

Quote:
LPC_12C->STAT
LPC_12C->CONCLR
LPC_12C->CONSET
LPC_IOCON
LPC_SYSCON    

It is a common 'trick' in embedded development to define a struct exactly matching the register layout of a peripheral,
and creating an instance of this struct at the actual address of the peripheral. This way, you can have the compiler
and linker fiddle with this addresses, while having nice looking and portable source code.
The header file defining this structs are usually supplied by the silicon vendor. In this case, ARM and NXP.
Note that all those structured register definitions are declared 'volatile'. That keyword used rather frequently in embedded SW.

To come to the point:
In addition to the CMSIS files and the user manual, I suggest to grab a tutorial to embedded C programming.
There are plenty around on the net. And it has not necessarily to be one for ARM Cortex controllers.
0 Kudos

394 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Mon Aug 13 00:45:22 MST 2012
These are defined in the CMSIS library/project for your part. It provides header files and a library to simplify access to the peripherals. Import any of the examples for LPC1114 and you will find
- CMSIS library
- some examples that use the library

Enjoy!
0 Kudos

394 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon Aug 13 00:44:46 MST 2012

Quote:
The datasheet does describe the registers but not their "names" in the compiler.

If you search for 'LPC1114' keyword at

http://www.nxp.com/

you also find an 'User Manual', UM10398 LPC111x/LPC11Cxx User manual Rev. 11 — 26 July 2012:

http://www.nxp.com/documents/user_manual/UM10398.pdf


Quote:
...where do I get information regarding the "names/pointers"...

Follow your header, CMSIS inc folder is including 'LPC11xx.h' with a lot of funny structs

/*------------- Inter-Integrated Circuit (I2C) -------------------------------*/
/** @addtogroup LPC11xx_I2C LPC11xx I2C-Bus Interface
  @{
*/
typedef struct
{
  __IO uint32_t CONSET;                 /*!< Offset: 0x000 I2C Control Set Register (R/W) */
  __I  uint32_t STAT;                   /*!< Offset: 0x004 I2C Status Register (R/ ) */
  __IO uint32_t DAT;                    /*!< Offset: 0x008 I2C Data Register (R/W) */
  __IO uint32_t ADR0;                   /*!< Offset: 0x00C I2C Slave Address Register 0 (R/W) */
  __IO uint32_t SCLH;                   /*!< Offset: 0x010 SCH Duty Cycle Register High Half Word (R/W) */
  __IO uint32_t SCLL;                   /*!< Offset: 0x014 SCL Duty Cycle Register Low Half Word (R/W) */
  __O  uint32_t CONCLR;                 /*!< Offset: 0x018 I2C Control Clear Register ( /W) */
  __IO uint32_t MMCTRL;                 /*!< Offset: 0x01C Monitor mode control register (R/W) */
  __IO uint32_t ADR1;                   /*!< Offset: 0x020 I2C Slave Address Register 1 (R/W) */
  __IO uint32_t ADR2;                   /*!< Offset: 0x024 I2C Slave Address Register 2 (R/W) */
  __IO uint32_t ADR3;                   /*!< Offset: 0x028 I2C Slave Address Register 3 (R/W) */
  __I  uint32_t DATA_BUFFER;            /*!< Offset: 0x02C Data buffer register ( /W) */
  __IO uint32_t MASK0;                  /*!< Offset: 0x030 I2C Slave address mask register 0 (R/W) */
  __IO uint32_t MASK1;                  /*!< Offset: 0x034 I2C Slave address mask register 1 (R/W) */
  __IO uint32_t MASK2;                  /*!< Offset: 0x038 I2C Slave address mask register 2 (R/W) */
  __IO uint32_t MASK3;                  /*!< Offset: 0x03C I2C Slave address mask register 3 (R/W) */
} LPC_I2C_TypeDef;
/*@}*/ /* end of group LPC11xx_I2C */
0 Kudos

394 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by yanvasilij on Mon Aug 13 00:41:23 MST 2012
The C Programming Language Ritchie & kernighan )). You should to read pointers to structures
0 Kudos