Datasheet

UM10398 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2014. All rights reserved.
User manual Rev. 12.3 — 10 June 2014 322 of 547
NXP Semiconductors
UM10398
Chapter 17: LPC11Cxx C_CAN on-chip drivers
17.4.2 CAN initialization
The CAN controller clock divider, the CAN bit rate is set, and the CAN controller is
initialized based on an array of register values that are passed on via a pointer.
void init_can (uint32_t * can_cfg, uint8_t isr_ena)
The first 32-bit value in the array is applied to the CANCLKDIV register, the second value
is applied to the CAN_BTR register.
The second parameter enables interrupts on the CAN controller level. Set to FALSE for
polled communication.
Example call:
ROM **rom = (ROM **)(0x1fff1ff8);
uint32_t CanApiClkInitTable[2] = {
0x00000000UL, // CANCLKDIV
0x00004DC5UL // CAN_BTR
};
(*rom)->pCAND->init_can(&CanApiCanInitTable[0], 1);
17.4.3 CAN interrupt handler
When the user application is active, the interrupt handlers are mapped in the user flash
space. The user application must provide an interrupt handler for the CAN interrupt. In
order to process CAN events and call the callback functions the application must call the
CAN API interrupt handler directly from the interrupt handler routine. The CAN API
interrupt handler takes appropriate action according to the data received and the status
detected on the CAN bus.
void isr (void)
The CAN interrupt handler does not process CANopen messages.
Example call:
(*rom)->pCAND->isr();
For polled communication, the interrupt handler may be called manually as often as
required. The callback functions for receive, transmit, and error will be executed as
described and on the same level the interrupt handler was called from.
17.4.4 CAN Rx message object configuration
The CAN API supports and uses the full CAN model with 32 message objects. Any of the
message objects can be used for receive or transmit of either 11-bit or 29-bit CAN
messages. CAN messages that have their RTR-bit set (remote transmit) are also
supported. For receive objects, a mask pattern for the message identifier allows to receive
ranges of messages, up to receiving all CAN messages on the bus in a single message
object. See also Section 16.7.3.4
.