Keil Logo

Peripheral Simulation

For Infineon C505C-2R — CAN Controller

Simulation support for this peripheral or feature is comprised of:

  • Dialog boxes which display and allow you to change peripheral configuration.
  • VTREGs (Virtual Target Registers) which support I/O with the peripheral.

These simulation capabilities are described below.

CAN Controller Configuration Dialog

CAN Controller  Configuration

The Controller Area Network (CAN) Controller Configuration tab configures the on-chip CAN controller. The CAN controller provides storage for up to 15 message objects which can be a maximum of 8 bytes long.

Power Group

  • CSWO (CAN Switch Off) is set if the CAN controller is disabled. If reset, the CAN controller is enabled (default after a reset).

Control Group

  • CR (CAN Control Register) contains the Test mode (TEST), Initialization (INIT) and Configuration Change Enable (CCE) control bits.
  • TEST (Test Mode) is used only during chip production testing. This bit must always be reset when writing to the CAN Control Register.
  • INIT (Initialization) is set to to perform a software initialization the CAN Controller.
  • CCE (Configuration Change enable) is set to allow the microcontroller access to the bit timing register.

Bit Timing Group

  • BTR0 (CAN Bit Timing Register Low) contains the Synchronization Jump Width (SJW) and Baud Rate Prescaler (BRP) settings.
  • BTR1 (CAN Bit Timing Register High) contains the Time Segment Before Sample Point (TSEG1) and Time Segment After Sample Point (TSEG2) settings.
  • CMOD (CAN Controller Prescaler Selection) is set to disable the divide by 2 prescaler. If reset, enables the divide by 2 prescaler.
  • Baudrate displays the current baud rate based on the Baud Rate Prescaler (BRP) value.
  • BRP (Baud Rate Prescaler) contains the value-1 to be divided into the oscillator frequency to generate the desired baud rate.
  • TSEG1 (Time Segment Before Sample Point) contains the number of time segments (from 1 to 7) within 1 bit time to wait before sampling 1 bit of data.
  • TSEG2 (Time Segment After Sample Point) contains the number of time segments (from 2 to 15) within 1 bit time to wait after sampling 1 bit of data.
  • SJW (Synchronization Jump Width) contains the maximum number of time segments 1 bit time may be reduced or lengthened during message re-synchronization.

Status Group

  • SR (CAN Status Register SR) contains the Busoff (BOFF), Error Warning Status (EWRN), Received Message Successfully (RXOK), Transmitted Message Successfully (TXOK) and Last Error Code (LEC) status information.
  • LEC (Last Error Code) displays the last error code reported on the CAN bus.
  • TXOK (Transmitted Message Successfully) is set when the last message was sent with no errors.
  • RXOK (Received Message Successfully) is set when a message was received with no errors.
  • EWRN (Error Warning Status) is set when the error counter limit reaches 96.
  • BOFF (Busoff Status) is set when the bus off state of the CAN Controller is set.

Global Mask Group

  • GMS (Global Mask Status) contains the 11-bit identifier mask. Bits 0-4 of the upper byte of this register are always set. Disable the Extended Identifier (XTD) bit to use this mask.
  • UGML (CAN Upper Global Mask Long Register) contains bits 28-13 of the 29-bit identifier mask. Enable the Extended Identifier (XTD) bit to use this mask.
  • LGML (CAN Lower Global Mask Long Register) contains bits 12-0 of the 29-bit identifier mask. Enable the Extended Identifier (XTD) bit to use this mask. Bits 0-2 of the upper byte of this register are always reset.
  • Mask(11-bit) displays the 11-bit identifier mask value.
  • Mask(29-bit) displays the 29-bit identifier mask value.

Interrupts Group

  • IR (CAN Interrupt Register) contains the identifier of a CAN interrupt request. If zero, no CAN interrupts are pending.
  • IE (CAN Interrupt Enable) is set to allow the CAN controller to generate interrupts. If reset, the CAN controller cannot generate interrupts.
  • SIE (CAN Status Change Interrupt Enable) is set to generate an interrupt when a message transfer completes, or when the controller detects a CAN bus error.
  • EIE (CAN Error Interrupt Enable) is set to generate an interrupt when either Busoff (BOFF) or Error Warning Status (EWRN) status bits change.

Mask of Last Message (Channel 15) Group

  • UMLM (Upper Mask of Last Message Register) holds bits 28-13 of the mask value used for the last incoming message.
  • LMLM (Lower Mask of Last Message Register) holds bits 12-0 of the mask value used for the last incoming message.
  • Mask (11-bit) displays the 11-bit last message mask.
  • Mask (29-bit) displays the 29-bit last message mask.

CAN Controller - Channel Dialog

CAN Controller - Channel

The Controller Area Network (CAN) Controller Channel tab displays and configures the channel settings for the 15 message channels on the on-chip CAN controller. The list box displays the current setting for each channel. Use the Select Channel group below the change channel settings.

Select Channel Group

  • ID (Message Identifier) displays the 11-bit or 29-bit message identifier, depending on the state of the Extended Identifier (XTD) bit.
  • XTD (Extended Identifier) is set if the message contains 29-bit identifiers, or reset if the message contains 11-bit identifiers.
  • DIR (Message Direction) is set for transmitted messages, and reset for received messages.
  • UAR (Upper Arbitration Register) contains bit 28-13 of the identifier mask used for bus arbitration.
  • LAR (Lower Arbitration Register) contains bit 12-0 of the identifier mask used for bus arbitration.
  • Length (Data Length) contains the length of the data in this message. Data can be from 0 to 8 bytes long.
  • Data displays the data for this message in hexadecimal format.
  • MSGVAL (Message Valid) is set when a message object is valid. Software resets this bit to indicate a message is no longer needed.
  • INTPND (Interrupt Pending) is set when a message object generates an interrupt.
  • RXIE (Receive Interrupt Enable) is set when a frame is received without error.
  • TXIE (Transmit Interrupt Enable) is set when a frame is sent without error.
  • NEWDAT (New Data) is set when the data portion of the message object is updated.
  • MSGLST / CPUUPD (Message Lost / CPU Update) If receiving a message, this bit is set if the data portion of the message object is updated while the NEWDAT flag was set. This means the previously stored data was lost. If transmitting a message, the CPU sets this bit to indicate a message may not be transmitted at this time.
  • TXRQ (Transmit Request) is set to indicate the CPU or remote node requested a message transmission, but not completed it.
  • RMTPMD (Remote Pending) is set to indicate that the CAN controller received a requested for a message transmission, but it has not been transmitted. When this bit is set, the CAN controller sets TXRQ.

CAN Controller -- Communication Dialog

CAN Controller -- Communication

The Controller Area Network (CAN) Controller Communication tab displays the CAN communication activity on the CAN bus. The Message number, States, Message Identifier, Message Direction, Channel, Data Length and Data content are displayed for each message. To clear the message display, double-click anywhere in the message display area.

CANBx VTREG
Data Type: unsigned char

The CANBx VTREGs contains the eight bytes of the CAN message. CANB0 is the first byte, CANB1 is the second byte, and so on.

  • When the simulated MCU transmits a CAN message, these VTREGs contain the message data bytes.
  • To simulate a received CAN message, these VTREGs must be initialized with the message data bytes.

CANID VTREG
Data Type: unsigned long

The CANID VTREG specifies the ID of the CAN message.

  • When the simulated MCU transmits a CAN message, this VTREG contains the message ID.
  • To simulate a received CAN message, this VTREG must be initialized with the message ID.

CANIN VTREG
Data Type: unsigned char

The CANIN VTREG specifies the type of CAN message the simulated MCU will receive. The values 1-4 are used:

  • 1: Message with 11-bit ID.
  • 2: Message with 29-bit ID.
  • 3: Message Request with 11-bit ID.
  • 4: Message Request with 29-bit ID.

For example:

CANIN=2;  // Input a 29-bit ID message

The following debugger function shows how you can receive CAN messages into your application.

func void CAN_Send (unsigned char msgno) {

switch (msgno)
  {
  case 0:
    CANB0=' '; CANB1=' '; CANB2='K'; CANB3='E';
    CANB4='I'; CANB5='L'; CANB6=' '; CANB7=' ';
    CANL=8;
    break;

  case 1:
    CANB0='S'; CANB1='o'; CANB2='f'; CANB3='t';
    CANB4='w'; CANB5='a'; CANB6='r'; CANB7='e';
    CANL=8;
    break;

  default:
    CANB0='H'; CANB1='e'; CANB2='l'; CANB3='l';
    CANB4='o'; CANB5='!'; CANB6=' '; CANB7=' ';
    CANL=6;
    break;
  }

CANID = 456;
CANIN = 1;
}

CANL VTREG
Data Type: unsigned char

The CANL VTREG specifies the length of the CAN message in bytes.

  • When the simulated MCU transmits a CAN message, this VTREG contains the number of bytes in the message.
  • To simulate a received CAN message, this VTREG must be initialized with the number of bytes in the message.

CANOUT VTREG
Data Type: unsigned char

The CANOUT VTREG specifies the type of CAN message that was transmitted by the simulated MCU. The values 1-4 are used:

  • 1: Message with 11-bit ID was sent.
  • 2: Message with 29-bit ID was sent.
  • 3: Message Request with 11-bit ID was sent.
  • 4: Message Request with 29-bit ID was sent.

The following debugger signal function shows how you can monitor and report on CAN messages transmitted by your application.

signal void CAN_Recv (void) {
while (1)
  {
  wwatch(CANOUT);

  printf ("Received CAN Message\n");
  printf ("CAN ID %4.4lX (%u): ", CANID, (unsigned) CANL);
  printf ("%2.2X %2.2X %2.2X %2.2X %2.2X %2.2X %2.2X %2.2X ",
    (int)CANB0, (int)CANB1, (int)CANB2, (int)CANB3,
    (int)CANB4, (int)CANB5, (int)CANB6, (int)CANB7);
  printf ("\n");
  }
}
Get more information about the
Peripheral Simulation Capabilities
of the µVision Debugger.
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.