 Hello, in this video, I will demonstrate to you how to configure and use DMI multiplexer with request generator usage. Pre-requisites for this session. I will use Nucleo C031C6 board, which will be connected to our PC with micro USB cable. And then from self-roof point of view, I will use STM4TataCube IDE inversion at least 1.10.1 and STM4TataCube library inversion at least 1.0.0. Here on the screen, we can see as well that blow button will be used to generate an external signals as it is connected to PC13 pin on our microcontroller. Example description. On the left part of the screen, we can see the block diagram of our application. We will use an external interrupt on PC13, our blue button, timer 14 working in PWM configuration without output signal generation, and USART2, which is connected to S-Tilling as virtual comport on PC. Each blue button press generates a synchronization signal on the DMA multiplexer, which is triggering a single DMA transfer from Pulse's SRAM buffer to timer 14 prescalar register, changing its affective frequency. Then on its output compare signal, so in the middle, this timer 14 is triggering DMA multiplexer once again using its synchronization signal, which is triggering another DMA transfer, this time from TX buffer to USART2 transfer register, character by character. So it will be visible as a single letters displayed on the terminal. Bit more details concerning our target application. Timer 14 is configured in PWM mode, initially 10 Hz frequency 50% duty cycle. Prescalar of this timer will be changed among predefined values on each blue button press. As timer 14 has no direct connection to DMA, we will use DMA request generator 0 to perform such a connection. Blue button press generates external interrupt on line 13, which triggers a single transfer between SRAM and the timer 14 prescalar register using DMA generator 0. USART2 is configured in asynchronous mode on PA2 and PA3 pins, which are connected to on-board ester link, and this interface should be configured as 115,000 bits per second, 8-bit data, one stop bit and no parity. USART2 additionally uses DMA to transfer data from another SRAM buffer called TXnata or Txbuffer to transmit character by character one string to the terminal output. Each output compare event from timer 14 generates such single transfer of the character from the buffer to the USART2 transmit register. String timer 14 prescalar causes change of the simple message string display speed. I'm opening stm32cube IDE. My location is this one, so I just click launch and create a new stm32 project. Okay, our target microcontroller will be C031C6. You can see the board already, so you press next. The name of the exercise I would propose, similar name is already there, so I would just shorten it. We will use a default clock configuration, let's have a look how does it look like, so we will use internal MSI 48 MHz divided by 4, so the system clock will be 12 MHz, we will use the same clock for our interface, so USART and timers. So no change there, we will then pin out the configuration, I will configure first the PC 13 as external interrupt 13 line and I need to enable interrupt from this, so I will go to system and core nvc, it is not there, so the give GPIO, nvc and enable interrupt. The next step would be configuration of timer 14, which we will use in our exercise, so I'll go to timers, timer 14, I just activate it and I will use timer, this timer in PWM mode, but without signal generation on the pin. As we are using 12 MHz system clock and we will have 10 Hz signal initially here, so I would propose at the beginning 12000-1 in the prescaler, in the counter period I would use 100-1 as we are counting from 0, so 99 and the pulse will be the half of it, so 50. No other components, no other configuration needed. Then connectivity, it will be USART2 asynchronous mode on PA2-PA3, so no need to change. In parameter settings we will keep the default ones, so moderate 115000 bits per second, 8-bit data, no parity and 1-stop bit. The only thing which needs to be done here is a DMA configuration, so I will just add USART2 TX, because we need to send some data over USART2 in circular mode, from memory to peripheral, byte into, in peripheral and the memory side of the communication and incrementation on memory side. Additionally, we need to enable the synchronization, synchronization signal would be XT, not here, it will be Timer 14 output compare and then signal polarity will be exactly this and request number it would be 1, because we need to send only one character on each output compare signal coming from Timer 14. So that's all configurations for USART2, we are going to DMA, so again system core and DMA, we need to enable another DMA channel, it will be our DMA request generator, so I just click add and I will select the first option, it will be again memory to peripheral, so from the one of the buffers in the SRAM to Timer 14 prescalar, circular, this time it will be word, incrementation on memory side, we will not use any synchronization in this case, but we need to configure this request generator settings, so the signal, it will be our XT13 and request number it will be again 1, so that's all configuration, we can generate the project, so I will just click this device configuration tool code generator, okay, after the code generation we can do some code processing, so let's open main.cfile, it should be done automatically after the generation of the code, but in case it is not done on your side, please unscrew the project, then find the core folder and within this SRC subfolder please open main.cfile, you can use this button over here just to link the file of the explorer position, so in case you've got multiple main.cfiles coming from different projects, you can always be sure that you are editing the proper file on your side, okay, so let's start from some variables declaration, so line 51 of an user code begin private variable section pv and we will declare over here two tables, the first one will be the string which will be displayed over usert, character by character, in our case it will be simple message, but you can use any other one and the second one will be the table of three values, 32-bit long one, which will be used to program the prescalar of our timer 14 and this prescalar will have an effect of changing the speed of displaying the data over the user, so let's start from the string to be displayed and the second one the 32-bit values, next point would be activation of the peripheral switch we use, so as we scroll down we can see the main function initialization of the hold and system clock, then initialization all the peripherals we just selected within the configuration phase and in line more or less 102 we've got the proper area where we can put the activation of our peripherals and it should be done before the main while one loop, so we'll start from the enabling the request generator which we configured, so request generator zero in our case, it is available within dma library, but it's extended version because dma multiplexer is not existing in all of the stm-42s, so it will be in this extended part and we've got already the proper function by control space and argument, this is the first one because the second dma channel is used for use r2, the first one is really the dma generator, then we need to start a dma using this generator, so I would use the function how dma start and then we've got the first the handler then the source address, so we need to copy the data from the timer 14 underscore prescalar table to prescalar register of timer 14, so let's start from some casting to be sure that everything will go correctly, then our table and destination address it would be really the address of the register, so again our start of some casting then the address address, so like this and 14 and we need to select from the list proper register, then the data length it will be free because we've got three values over there, the next point would be the start of the transmission the data over the user using dma, so we need to select transmit function from usert drivers, the handler of the usert, the buffer name and its size, we can use size off over here and the last point would be the start of our timer 14 in PWM mode, so as you remember we configured timer 14 as in PWM mode without any connection to the external pin but we can use still the activation on the channel one, so how team PWM start and no dma, no interrupts, we need handler to timer 14 and our channel channel one and that's it, the code part is done, I need to build it using the hammer icon in the meantime I can connect my board, there is some error, so let's have a look and now it's better, errors, zero warnings, now after the connection of the board I can start a debug session, clicking on this bug icon, we need a terminal application within this lab, so I will use the build in one, I will check whether there is no active one from the previous sessions, yes there is one, so let me just disconnect and disable it and I will create a new one just to demonstrate to you how to do this, so before starting the project let's go below and within this open console button I click on this down arrow, select common shell console, serial port as a connection type, connection name, I will select something different, let's call it TT, serial port usually the highest possible numbers as virtual comport are landing over there, the default settings for the board rate 115,000 bits per second, I bid data, no party T and one stop bid, let's click OK and I can see that my TT terminal is already connected, so I can start the application and I can see that the simple message string is displaying and I will press the blue button and as you can see the speed is changing on each button press, now it's the fastest one, the prescaler has the lowest number, now I'm changing to once again, so from this 3000 we are landing to 12,000 inside the prescaler and I'm changing right now for the middle value and again for the fast one, in case I would like to disconnect from the terminal I can click on this icon, click again on the connect will give me the opportunity to connect to my terminal once again, so the lab is ready, you can play with the parameters, change the settings to observe the effect, but as you can see using this DMA generator it is pretty easy to connect other peripherals even if those are not directly connected to DMA, so in this lab we demonstrated how to connect timer 14 using DMA request generator to the DMA and unload the microcontroller and put some more load on the DMA. Further information you can find within different documents, here I'm mentioning two application notes the first one AN-5224 STM-42 DMA MOOCs just about this DMA multiplexer and another one bit more generic one it is AN-2548 it is about DMA controller among different STM-42 devices, you can find as well a lot of information about DMA and DMA multiplexer within dedicated reference manual for STM-42C0 family like RM-0490. Thank you for your attention.