 STM32-WL55 dual-core project inter-processor communication controller. What are the goals of this session? Using STM42Q by DE, I will demonstrate how to select, configure and use inter-processor communication controller and shared memory concept. Then we'll monitor preference within debug session using the project running on two cores and by using built-in single-wire viewer with an STM32Q by DE, we'll monitor in graphical way some variables modified by both cores. Before this, I would spend a while on discussion about theoretical points related to inter-processor communication controller. Pre-requisites. We'll run this example on a Nucleo W155 JC2 board. This board will be connected to PC using micro USB cable. Additionally, we would need one single wire to connect two standard gold pins on the board and this is raster 2.54 mm. We would need as well PC with pre-installed the following software. STM42Q by DE in version at least 1.5.0 and STM42Q by WLQ library in version at least 1.0.0. Inter-processor communication controller IPCC theory. Inter-processor communication controller is used for communication between two cores. CPU1 or C1 is assigned to Cortex-M4 and CPU2 or C2 is assigned to Cortex-M0+. Inter-processor communication IPCC contains 12 channels, 6 per each direction, CPU1 to CPU2 and 6 from CPU2 to CPU1. These channels can work in simplex mode where data transfer is in a single direction from sending to receiving core and it can work as well in half duplex mode when both cores are exchanging data. So after one core sends data, the other one sends a response to it. This is kind of ping-pong operation. Inter-processor communication controller can generate interrupts on selected, means masked channels activities. Once the data has been loaded into shared area, so this is IPCC underscore x underscore occupied flag and once data has been read from shared area and this is IPCC underscore tx underscore free flag. To exchange data, both cores must use the same IPCC channel and the same shared memory buffers so it requires some modification on their linker file. IPCC doesn't handle buffers nor memories so it is up to the developer to handle them. Configuration flow using HAL libraries done with a code generated by STM32 cube mix or STM32 cube IDE to activate and use IPCC controller. It is necessary to enable IPCC's interface clock. Then in case of interrupt mode selection, which is a default setting of cube mix and cube IDE generated code, we need to configure the IPCC interrupt priority and enable its NVIC channel. In case of polling mode, it is up to the user to poll the status of the communication. Most of the configuration of IPCC is done with an user code. So STM32 cube mix and STM32 cube IDE are just enabling the IPCC, its clock and its interrupt. Communication flow using HAL libraries with an user configuration part. So after we will generate the basic skeleton of the application with IPCC using STM32 cube IDE or STM32 cube mix, we need to select the IPCC channel from 0 to 5 for both cores and it needs to be the same for both cores. And then we need to specify the direction of the communication. It should be IPCC underscore channel underscore, dir underscore tx for the core, which would transfer the data and it should be Rx for the core, which would accept the data. Then we need to select the communication mode. So it can be either polling or interrupt mode. Then in case of interrupt mode, we need to implement the interrupt callbacks for transmission and reception. And the last point is to associate the callback to the corresponding channel and direction using HAL underscore IPCC underscore activate notification function. Communication flow using HAL libraries polling mode. To send information, please use HAL underscore IPCC underscore notify CPO function with IPCC channel, dir tx argument. And to know when the other processor has handled the notification, please poll the communication using HAL underscore IPCC underscore notify CPO function with IPCC underscore channel underscore dir underscore tx argument. To receive information, poll the status of the communication with HAL IPCC get channel status function with IPCC channel dir Rx argument. And to notify the other processor that the information has been received, please use HAL underscore IPCC underscore notify CPO function with exactly the same argument. Communication flow using hardware abstraction layer libraries in interrupt mode. To use IPCC in interrupt mode, we need to implement a callback function or functions which will be called at the end of IPCC interrupt. Before that, we need to assign a callbacks. So the function names for the channel and the direction using HAL IPCC on activate notification functions. This should be done for both directions or the direction we would like to use within the selected core. The directions can be either transmit, so Tx or reception, so Rx what you can see on the screen. Then to transmit an information, so after transmission of the information to the shared buffer, we need to use afterwards the HAL underscore IPCC underscore notify CPO function with IPCC underscore channel underscore dir underscore Tx argument. And the callback related to this direction would be called once this notification has been sent because this notification was triggering the interrupt which would be handled by the other processor which has this notification enabled. To receive an information, the callback configured within HAL underscore IPCC underscore I to activate notification function and the Rx argument will be triggered on reception of the communication. To notify the other processor that the information has been received, we need to use HAL underscore IPCC underscore notify CPO with this Rx argument. IPCC in simplex mode. What you can see on the screen is a communication between both cores called processor A and processor B. So processor A is sending some data, so write communication data. After this, it is sending the function HAL IPCC notify CPO which is triggering the interrupt or an Rx direction on processor B and it is interrupt is let's say triggering the read communication data on processor B side. And after completion of this read operation, processor B is triggering again the function HAL underscore IPCC notify CPO which can trigger the same interrupt on transmit side on processor A. In this particular case, it is clearly just clearing the flag on the selected IPCC channel which allows processor A to write next data on the shared buffer. IPCC have duplex mode. Here we can see the communication between both processors, processor A and B. It can be Cortex-M4 and Cortex-M0 plus like in our example. So processor A is writing some data to the communication channel, so to the shared buffer. After this, it is sending the notification using HAL underscore IPCC underscore notify CPO function and it is triggering the Rx occupied interrupt on processor B side. Then the processor B based on this interrupt is reading the data and once it reads the data, it can write any response to the shared buffer. As you can see this channel on IPCC selected channel, it is still on active side. So it blocks processor A from sending new data over there. So after writing the response by the processor B, processor B is calling HAL underscore IPCC underscore notify CPO function which is triggering the Tx so transmit free interrupt on processor A side. This is clearing this channel flag for the IPCC which is used to communicate between both cores and it allows processor A to send the new data over this shared channel. So we can see it on the screen later on. So processor A is reading a response then writing the communication data and after this it is again is calling the function HAL underscore IPCC notify CPO which is raising the Rx interrupt on processor B side and processor B, when this interrupt, it is reading the data, writing a response and it is triggering again the Tx free interrupt on processor A side and we can see this ping pong operation it can continue like this. Interprocessor communication IPCC API key functions from STM32WLXX underscore HAL underscore IPCC.C file. STM32WL HAL functions present with an STM32 cube mix or STM32 cube ID generated code are the following. So the function executed from main function added initialization stage so this is main.C file for both cores is HAL underscore IPCC underscore init function with a handler to IPCC as an argument. Then the function which is executed from HAL IPCC init to set the priority and enable the interrupt from this for this peripheral it is HAL underscore IPCC underscore MSP init function and it is a starter with an HAL underscore MSP dot C file for both cores. So those two functions are generated automatically by cube mixer cube IDE. Then we've got as well the skeletons of the functions of an WL underscore IT dot C file so the file for interrupts and we can see there already HAL underscore IPCC underscore TX or RX underscore IRQ handler so there are two separate functions for transmit and receive direction for IPCC peripheral and those functions are generated automatically and start within this interrupt dot C file. Configuration of selected IPCC channel with activation of its notifications via interrupt is done by HAL underscore IPCC underscore activate notification function. It requires four arguments. The first one is IPCC handler. The second one is IPCC channel. It can be the number from zero to five. Then there's a direction so it can be either transmit or receive what we can see on the screen and then the last argument is a callback function which will be called at the end of the interrupt service routine in case of interrupt trigger. The return value can be either HAL okay means zero and it means that the operation was successful or HAL error which means that IPCC was busy not initialized or its handler is not defined. It is possible to deactivate notifications so interrupt triggering on select channels using HAL underscore IPCC underscore deactivate notification functions. It needs three arguments. The first one is IPCC handler. The second one is selected channel. It can be number from zero to five. And the last argument is a direction so it can be either IPCC underscore channel underscore DIR underscore TX for the transmit direction or RX for the receive direction. This function will return one of the values either HAL underscore okay once the operation is successful or HAL underscore error in case of any problem. So it can be IPCC busy state or IPCC can be not initialized or its handler is not defined yet. One of the most important functions so when IPCC HAL library function set it is HAL underscore IPCC underscore notify CPO. This function is creating a notification to the core the course about operation on the shared buffer. So write or read operation in fact. So it requires three arguments. The first one is IPCC handler. The second one is a channel. So it can be from zero to five. And the second one is IPCC channel direction so it can be either transmit so TX or reception so RX. Once we activate the notifications this function will trigger an interrupt on the second core informing it about the change in the shared buffer. Thank you for watching this video.