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]andISAA[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:
- PCI device driver โ handles resource discovery and mapping
- 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 descriptorCAN_CHANโ communication channel and callback interface
Initialization (canOpen) #
-
Configure SJA1000:
- Baud rate
- Acceptance filters
- Operating mode
Data Flow #
canWrite()queues outgoing framescanRead()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.