This example application bridge the CAN Bus and Wi-Fi peripherals to enable data transfer between CAN nodes and Wi-Fi peripherals.
This sample application demonstrates how to bridge up the CAN Bus and Wi-Fi peripherals on the WFI32E device which is running in SoftAP Mode. This concentrator device allows to connect the physical CAN-bus to WLAN network. A third-party STA will connect to the WFI32E SoftAP device and a third-party CAN Bus node (Microchip CAN Bus Analyzer) will connect to the CAN Bus of the WFI32E device.
A TCP Client on the third-party STA will then connect to the TCP Server running on the WFI32E Bridge device. Once connected, the WFI32E device will be able to transmit or receive the network data from the TCP Client. The WFI32E device can also transmit or receive CAN Bus messages from the third-party CAN Bus node.
In this example, the CAN messages are sent from the Microchip CAN Bus Analyzer. The WFI32E Bridge device forward the CAN Bus messages to the TCP Client (python script) running on a third party STA (computer). The TCP Client (python script) echoes the same message back to the SoftAP device and the WFI32E forward the message back to the CAN Node (Microchip CAN Bus Analyzer).
- CAN Bus Analyzer Software v2.3 (The tool requires .NET Framework 3.5, if you are facing an issue while installing it on a Windows 10 computer, checkout here).
The sample project has been created and tested with the following Software Development Tools:
-
MPLAB X IDE v5.50
-
MPLAB XC32 v2.50
-
MPLAB Harmony v3.6.4
- mhc v3.7.1
- csp v3.9.1
- core v3.9.1
- wireless_wifi v3.4.1
- dev_packs v3.9.0
- wireless_system_pic32mzw1_wfi32e01 v3.4.1
- wolfssl v4.7.0
- net v3.7.2
- crypto v3.7.1
- CMSIS-FreeRTOS v10.3.1
-
Python to run the TCP Client Script
-
To run the demo, the following additional hardware are required:
- Microchip CAN Bus Analyzer Hardware
- ATA6563 click board
- USB-to-UART cable
-
Computer connected to WFI32 Curiositiy board over USB POWER (J204)
-
J202 = VBUS
-
J301 = open
-
USB-to-UART cable between the computer and GPIO Header UART1 pins (Rx, GND, Tx) to observe the console logs.
-
Connect thru wiring the ATA6563 click board to the PIC32MZ W1 Curiosity Board as per the Pi connection below:
PIC32MZ W1 Curiosity Board | ATA6563 click board |
---|---|
AN (RPA14), mikroBUS connector | TX (pin 14) |
PWM (RPB12), mikroBUS connector | RX (pin 13) |
+3.3V, mikroBUS connector | 3V3 (pin 7) |
+5V, mikroBUS connector | 5V (pin 10) |
GND, mikroBUS connector | GND (pin 9) |
- Connect Microchip CAN Bus Analyzer Hardware to ATA6563 click board using female to female DB9 serial cable. On both end, the wiring must be direct between the relevant signals:
Pin no | Signal |
---|---|
1 | - |
2 | CAN-Low |
3 | GND |
4 | - |
5 | - |
6 | - |
7 | CAN-High |
8 | - |
9 | - |
-
Connect Microchip CAN Bus Analyzer Hardware to PC using USB Male-A to Male Mini-B cable
-
A laptop / mobile device is needed to run the TCP Client script
The ATA6563 click board carries the AT6563 high-speed CAN transceiver. The transceiver is designed for high-speed (up to 5 Mbps) CAN applications in the automotive industry, providing differential transmit and receive capability to (a microcontroller with) a CAN protocol controller. It offers improved electromagnetic compatibility (EMC) and electrostatic discharge (ESD) performance. The transceiver is CAN FD (Flexible data-rate) ready, meaning it has increased data rates in comparison with classic CAN. Check out the AT6563 datasheet for more details.
In this demo application, the ATA6563 click board communicates with the WFI32 MCU through CAN1 Bus Lines.
With PPS, the CAN1 RX Line (C1RX) is routed to pin RPA14.
And the CAN1 TX Line (C1TX) is routed to pin RPB12.
- Clone/download the repo
- Open the project with MPLAB X IDE
- Open Harmony Configurator
- Under Project Graph > Root, set the AP parameters required for a station device to connect to the Bridge in WIFI SERVICE
-
Under Project Graph > Root:
- Select Net Service
- Currently, NetService is configured to run a TCP Server which awaits connection from a TCP Client on port 5555.
-
(if required) Save configurations and generate code via MHC
-
Build and program the code
-
Open a serial terminal (e.g. Tera Term) on the computer
-
Connect to the USB-to-UART COM port and configure the serial settings as follows:
- Baud: 115200
- Data: 8 Bits
- Parity: None
- Stop: 1 Bit
- Flow Control: None
-
Reset WFI32E Curiosity Board by pressing MLCR button
-
The bridge device shall come up as SoftAP and then as per the default Net Service configuration, the TCP Server shall come up, awaiting a connection from a TCP Client.
- Connect a Station (Laptop) to the SoftAP (with ssid DEMO_AP_SOFTAP) running on the WFI32E device
- Observe the Station connected to SoftAP device
- Start a TCP Client using Python Script on laptop, giving the server IP as the PIC32MZW1 AP Mode IP Address, and the TCP port as 5555
tcp_client <SoftAP Ip Address> <Port No>
- TCP Server received a connection
- TCP Client is ready to receive data
- Open CAN Bus Analyzer software and make the following configurations:
Description | Settings |
---|---|
CAN Bitrate Control | 500 Kbps |
CAN Mode Control | Normal |
Bus Termination Control | ON |
-
Under Tools -> Transmit, send following CAN message from CAN Bus Analyzer software
- ID: 0x469, DLC: 8, DATA: 1, 2, 3, 4, 5, 6, 7, 8
- WFI32E Bridge display the message received on the console
- The Server transfer the CAN message received to the TCP Client. You can observe the CAN message on laptop command prompt.
- The TCP Client echo the same message back to the WFI32E (TCP Server).
- The WFI32E Bridge transfer the TCP Client message to the CAN Bus.
CAN Bus Analyzer software receives the message under Tools -> Rolling Trace.