Skip to main content

PCI-Based CAN Card Design and VxWorks Driver Development

·683 words·4 mins
VxWorks CAN Bus PCI Device-Drivers Embedded Systems RTOS Hardware Design C Programming
Table of Contents

PCI-Based CAN Card Design and VxWorks Driver Development

This article presents a practical implementation of a PCI-based CAN interface card and its corresponding driver under the VxWorks real-time operating system. The design targets high-reliability embedded systems, such as vehicle-mounted virtual instruments, where deterministic communication and robust hardware integration are essential.

๐Ÿงญ System Overview and Design Goals
#

In integrated vehicle electronic systems, CAN bus serves as the backbone for communication between control and measurement modules. The display terminal must:

  • Collect real-time data from CAN nodes
  • Process and visualize system parameters
  • Support command transmission and storage

To meet these requirements:

  • PCI/CompactPCI-based embedded platforms are used
  • VxWorks RTOS ensures deterministic scheduling and reliability
  • A custom PCI CAN interface card enables CAN connectivity

๐Ÿ”Œ Hardware Architecture of the PCI CAN Card
#

The design leverages a bridge-based architecture to simplify PCI integration.

Core Components
#

  • PLX PCI9052 โ€” PCI bridge controller
  • SJA1000 โ€” CAN controller
  • 82C250 โ€” CAN transceiver
  • 93LC46B EEPROM โ€” configuration storage
  • CPLD (EPM7064S) โ€” glue logic and signal control

โš™๏ธ PCI9052 and PCI Bus Integration
#

The PCI9052 operates in ISA mode, which simplifies local bus interfacing:

  • PCI interface connects directly to the host bus
  • Local bus emulates ISA timing and signaling
  • EEPROM stores:
    • Vendor ID / Device ID
    • Base Address Registers (BARs)

At system boot, the PCI9052 loads configuration from EEPROM, enabling automatic resource allocation.

๐Ÿ”— PCI9052 and SJA1000 Interface
#

Key signal connections:

  • BALE โ†’ ALE (address latch)
  • LAD[15:0] โ†’ 8-bit data bus
  • Address decoding via LA[23:2] and ISAA[1:0]
  • CLKOUT (SJA1000) โ†’ LCLK (PCI9052)
  • LRESET โ†’ reset logic (via CPLD)
  • INT โ†’ LINTi1 (interrupt line)

Design Notes
#

  • CPLD handles:
    • Address/data multiplexing
    • Reset polarity adjustment
  • Control signals (LRDY, CHRDY, etc.) are configured for timing compliance

๐ŸŒ CAN Physical Layer
#

The 82C250 transceiver provides:

  • Differential signaling (CANH/CANL)
  • High-speed mode configuration
  • Bus protection

Standard 120 ฮฉ termination resistors ensure signal integrity.

๐Ÿง  VxWorks Software Architecture
#

The software stack consists of two layers:

  1. PCI device driver โ€” handles resource discovery and mapping
  2. CAN device driver โ€” manages communication and protocol interaction

๐Ÿงฉ PCI Device Initialization
#

The driver identifies the device and retrieves assigned resources:

if (pciFindDevice(CAN_VENDOR_ID, CAN_DEVICE_ID, 0,
                  &busNo, &deviceNo, &funcNo) == ERROR) {
    printf("Cannot find the CAN card\n");
    return ERROR;
}

pciConfigInLong(busNo, deviceNo, funcNo, PCI_CFG_BASE_ADDRESS_0, &membaseCsr);
pciConfigInLong(busNo, deviceNo, funcNo, PCI_CFG_BASE_ADDRESS_1, &iobaseCsr);
pciConfigInByte(busNo, deviceNo, funcNo, PCI_CFG_DEV_INT_LINE, &irq);

Memory Mapping
#

sysMmuMapAdd(...);

This ensures that device registers are accessible in the system address space.

๐Ÿšฆ CAN Driver Implementation
#

The CAN driver follows the VxWorks I/O model and implements:

  • canOpen()
  • canClose()
  • canRead()
  • canWrite()
  • canIoctl()

Device Abstractions
#

  • CAN_DEV โ€” device descriptor
  • CAN_CHAN โ€” communication channel and callback interface

Initialization (canOpen)
#

  • Configure SJA1000:

    • Baud rate
    • Acceptance filters
    • Operating mode

Data Flow
#

  • canWrite() queues outgoing frames
  • canRead() retrieves received data via callbacks

โšก Interrupt Handling and Data Processing
#

Interrupt-driven design ensures real-time responsiveness.

Driver Setup
#

canDrvNum = iosDrvInstall(...);
pciIntConnect(..., can_interrupt, ...);
sysIntEnablePIC(irq);

ISR Design
#

void can_interrupt(void) {
    // Handle RX/TX events
    // Trigger callbacks
}

Callback Mechanism
#

CanCallbackInstall(...);

Benefits:

  • Decouples hardware layer from application logic
  • Enables flexible protocol integration
  • Reduces ISR workload

๐Ÿงช Testing and Validation
#

Hardware Verification
#

  • PCI device detected correctly by BIOS
  • Basic CAN communication verified under Windows

VxWorks Testing
#

  • Driver loaded successfully
  • Separate read/write tasks implemented
  • Stable communication with external CAN node

Results
#

  • Continuous frame transmission (100 ms interval)
  • No data loss observed
  • Deterministic system behavior achieved

๐Ÿญ Practical Design Considerations
#

Reliability
#

  • Proper interrupt configuration
  • Stable EEPROM initialization
  • Robust physical layer design

Performance
#

  • Use interrupt-driven I/O instead of polling
  • Minimize ISR execution time
  • Optimize buffer and queue management

Scalability
#

  • Modular driver structure supports extension
  • Callback mechanism enables protocol layering

๐Ÿ“Œ Conclusion
#

The PCI-based CAN interface card combined with a VxWorks driver provides a reliable solution for real-time embedded communication systems.

Key takeaways:

  • PCI9052 simplifies PCI integration without additional MCU
  • SJA1000 offers flexible and efficient CAN control
  • VxWorks enables deterministic interrupt handling and task coordination
  • Callback-based driver design improves modularity and scalability

This architecture is well-suited for high-reliability domains such as automotive, industrial control, and defense systems.

Related

CompactPCI on VxWorks: Driver Design and Interrupt Control
·599 words·3 mins
VxWorks CompactPCI Embedded Systems Device-Drivers Interrupt Handling PCI RTOS Real-Time Systems
VxWorks Serial Communication Design and Implementation Guide
·558 words·3 mins
VxWorks Serial Communication Embedded Systems RTOS Device-Drivers UART BSP Real-Time
Driving and Control Techniques for CompactPCI Bus under VxWorks
·1137 words·6 mins
VxWorks CompactPCI PCI RTOS Embedded Systems