CASP supports exchanging data between micro-controller and host computer with very low latency Ethernet communication. Data received from the micro-controller can then be used in CASP models on host computer or can be visualized with the help of CASP GUI widgets such as plotters, dials, 2D/3D graphs.
This example project demonstrates how to establish Ethernet communication between the STM32 board with on-board Ethernet and the host (native) computer using CASP. We try to acquire analog periodic signal from the target board to the host PC through Ethernet and plot the signal on the host computer. UDP protocol is used for communicating between the target board and the host PC.
Pre-Requisites
- STM32H743 Nucleo board that supports LwIP stack.
- A suitable signal generator to test the Ethernet latency of complete setup. If no signal generator is available, user can use Arduino Due or any CASP supported micro-controller board that can generate a DAC output, to generate a sine wave signal at frequencies between 1 to 100Hz
- CASP software is installed along with CASP Python Libraries (optional).
- STM32 BSP is installed.
- The project files are located at CASP installed directory ‘CASP/support/examples/communication/5_lwip’. These are also available for download at this link.
Connection Diagram

CASP Model for Arduino Due

Procedure
- Connect Arduino Due to the host PC via a USB cable.
- Note the serial port number to which the board is connected to the host PC, from the host operating system.
- Run CASP and load the ‘sig_gen_model’ project. Set the Signal Generator block frequency between 1Hz to 100Hz.
- Open Home->Simulation->Setup Simulation Parameters menu item. Under TargetHW->General tabs set ‘Target Programmer Port’ parameter to the serial port to which the board is connected.
- Build the model and program the board by clicking on Run button.
- After the board is programmed check whether the on-board LED is blinking and the DAC output is giving a sine wave with specified frequency.
CASP Model for STM32H743 Nucleo Board

Procedure
- Connect STM32 board to the host PC via a USB cable.
- Note the serial port number to which the board is connected to the host PC, from the host operating system.
- Run CASP and load the ‘target_model’ project.
- Open Home->Simulation->Setup Simulation Parameters menu item. Under TargetHW->General tabs set ‘Target Programmer Port’ parameter to the serial port to which the board is connected.
- Build the model and program the board by clicking on Run button.
CASP Model that runs on Host Computer

Procedure
- Run CASP and open the project ‘CASP/support/examples/communication/5_lwip/native_model/native_model.prj’ from CASP installed directory.
- Open the ‘native.wsp’ workspace file. Double click on the ‘Serial SimPanel’ block and set ‘Serial Port Settings->Serial Port’ parameter to the serial port to which the board is connected as shown in below figure.

- Click Run button to build the model and start simulation. A simulation panel window should open and communicate with the board. Screen shots for 10 Hz and 100 Hz sine wave input at the ADC port of Arduino Uno are shown below.


From the above screen shot, for the frequency of 100Hz, the number of sample points are enough to plot a reasonably smooth wave form. This indicate that the overall sampling rate of the setup (Nucleo Board ADC sampling rate + the Ethernet communication cycle time between target board and the host PC) is less than 500 micro-seconds. The measured round trip time between the host computer and STM32 board is around 200 micro seconds.