↓ Skip to main content

PCI-Based CAN Card Design and VxWorks Driver Development

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