C code question for 54102 part

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

C code question for 54102 part

643 Views
robertrobert
Contributor I

Hi All,

I am using a 54102 processor board from Coridium.

I am using the MakeItC compiler.

I am looking for just a small bit of help with a C statement for this board.

I have reviewed the NXP document for the part and the help I am requesting is a sample C statement that writes to a specific memory address.

That's my question.

Any other C source code that might be available for this part is a great interest to me, but for now I want to program the part by setting register values.

Many thanks,

robert

Tags (2)
0 Kudos
Reply
1 Reply

564 Views
bruceeisenhard
Contributor I

At the simplest level in C access to registers is through pointers for ARM processors.

* some_address = some_value;  // some_address is defined as a unsigned int pointer type (uint32_t most places)

In header files  (old school like me) would define in a header (.h file)

#define  LPC_GPIO_DIR    * (unint32_t *) 0x1C002000  // GPIO direction for Port 0

#define  LPC_GPIO_SET   * (unint32_t *) 0x1C002200  // GPIO set for Port 0

And to set say bit 4 high

LPC_GPIO_DIR   = (1 << 4);   // set pin/bit 4 of Port 0 as output

LPC_GPIO_SET  = (1 << 4);   // and set that pin high

More modern definitions of registers defines the structure of the set of registers in a header file.  So that the same code would be

LPC_GPIO->DIR[0] = (1 << 4);   //set pin/bit 4 of the DIR register of Port 0 GPIO structure (group of registers) as output

LPC_GPIO->SET[0] = (1 << 4);   // and set that pin high

And some "modern' (obtuse) definitions define them as inline code in a header (start the flame wars- an atrocious practice)

__STATIC_INLINE void Chip_GPIO_WritePortBit(LPC_GPIO_T *pGPIO, uint32_t port, uint8_t pin, bool setting)
{
 pGPIO->B[port][pin] = setting;
}


__STATIC_INLINE void Chip_GPIO_SetPinState(LPC_GPIO_T *pGPIO, uint8_t port, uint8_t pin, bool setting)
{
 pGPIO->B[port][pin] = setting;
}

0 Kudos
Reply