 Dans cette partie, nous allons parler de la DMA et de la DMMux de DSM32-G0, et ensuite, nous allons faire un lab en utilisant la DMA. Le accesse direct de la DMA, embêté dans le microcontroller DSM32-G0, est utilisé pour provider un transfert de data à haute vitesse entre les peripheraux et la mémoire, la mémoire et les peripheraux, et aussi entre la mémoire et la mémoire. Donc, nous avons besoin de la CPU. Donc, la CPU peut être utilisée pour faire d'autres opérations. Donc, les channels de DMMux peuvent accéder à chaque location de mémoire, incluant les peripheraux de haute vitesse, comme la CRC, les mémoires de haute vitesse, comme la SRAM, ou les peripheraux de haute vitesse, comme l'art de l'usage. La DMMux est un master sur le bus de haute vitesse. Donc, elle offre une configuration flexible, elle aussi donne du management de hardware et de software priorités. Il y a des modes de transfert différents, peripheraux à peripheraux, peripheraux à mémoire, mémoire à peripheraux et mémoire à mémoire. En termes de bénéfices de l'application, premièrement, la DMMux supporte différents peripheraux, comme les timers, les ADC et les peripheraux de communication. Cela offre le load de la CPU et permet une simple intégration. Les deux unités sont en charge d'un transfert de DMMux. La DMMux requiert de multiplexer et de DMMux, et le controller DMMux. Le controller DMMux transfert des données d'une adresse source à une adresse destination et manède la priorité entre les canaux. La DMMux enables l'utilisateur à appuyer des requêtes aux canaux. Elle aussi déclare des triggers et des synchronisations. Si nous comparons à la DMMux F0, nous verrons que les principales différences sont que la DMMux a deux différents DMAs, alors que la DMMux a un DMA. Les features de DMMux sont les mêmes, mais la différence principale est que la DMMux s'embête à DMMux, alors que la DMMux n'a pas la DMMux. La DMMux requiert de multiplexer permet de tourner une ligne de DMMux entre les peripheraux STM42G0 et ses controllers DMMux. La fonction de tourner est en train d'entraîner une ligne de multiplexer sur un multi-channel DMMux. Chaque chaîne sélectionne une ligne de DMMux inconditionnée ou synchronisée avec des événements de son input de synchronisation de DMMux. La DMMux peut aussi être utilisée comme un générateur de DMMux par des événements programmables sur ses signals de triggers d'input. La DMMux est utilisée pour appuyer les requêtes de peripheraux sur les 7 channels de DMMux. Cette appui est programmable. En plus, la DMMux s'embête à une requête 4-channel d'un générateur qui convertit les triggers dans les requêtes de DMMux. Les suivants triggers sont supportés. Les 16 externes interruptes, les 1ers timers de low power et les 2 timers, les compétences d'outils timers et les 4 événements générées par la DMMux. Let's recap the features of the DMM and DMMux inside the SMV2G0. So let's start with the DMMux. So the DMMux has 57 peripheral requests mapped to 7 DMM channels. 4 request generator channels, 23 trigger inputs and 23 synchronisation inputs. Now for the DMM features, it offers 7 channels. Now that we have learned a lot about the DMM, we can start a lab using the DMM. The objective of this lab is to open the SMV2QMX project IOC file from a SMV2G0 library example, so DMM example and we're going to review the configuration in SMV2QMX. Then we're going to run the Kailma Covision file so the ARM MDK project associated to the IOC file. So this example will be a DMM transfer memory to memory from flash to internal SRAM. Okay, first we're going to close Kailma Covision 5 and SMV2QMX if they open. Then we're going to open a Windows Explorer to go to the following location. So this location is basically on your user account in the SMV2QM directory repository. Then the name of the library so which is G0, then the version number, projects projects for the nuclear board that we're using. So this is the nuclear G071RB examples, DMM and then DMM flash to RAM. So once you open this you will find the IOC file and the projects in this location. So we're going to do that. First I'm going to close Kailma Covision and close SMV2QMX. Now we're going to find the DMM example. So I'm going to go to users STMV2QM repository SMV2G01.2.0 It could be different on yours. That's the version that I have so far. You could have a different version. Now I'm going to the projects. Look for the nuclear G071RB. That's the one we're using. Example and DMM then DMM flash to RAM. So here we can see that we have the IOC file. So the SMV2QMX project and also different projects for different IDs. So here the MDK arm that we'll be using. So we're going to open this IOC file. So just double-click on it and this is going to open SMV2QMX with the configuration for this project example. So I'm going to double-click on this IOC file to open the SMV2QMX project. So once SMV2QMX is open please go to the system view. So here click on system view and then DMM. Now we're going to study the DMM configuration. So to do this, so in DMM1 so in the configuration click DMM1 then DMM1 click on mem to mem and we're going to look at the channel views. So channel views is DMM1 channel 1. The direction is memory to memory and priority low. The mode is normal and we increment both the source and the memory address after each transfer. For the data width of the transfers they will be worldwide. So 32 bits. Ok, we're going to expand a little bit here to see better. All right. In configuration of DMM1 let's look at the DMM request that was configured for this example. So this is called mem to mem. So memory to memory. This is DMM1 channel 1. Memory to memory with a low priority. Both incrementation for the source and the destination address and the data width is 32 bits. So worldwide. And the mode is normal. Now if we look at the DMM configuration so same thing. You will go to system view then click on NVIC. So we should see that the DMM1 channel 1 interrupt is enabled like this. So it should be checked in the system view click on NVIC and we're going to check that the DMM1 channel 1 interrupt is enabled and this is the case. Ok, now we have reviewed the Sinfra to kubemax project and the configuration of the DMM for this project. Now we're going to open the project from the example. So the DMM example DMM flash to RAM. So as the name indicates we're going to do a transfer from flash to RAM using the DMM. So memory to memory as we saw in the configuration before. So what you're going to do in your explorer window you're going to go so we were here at the DMM flash to RAM and now we're going to click on the directory MDKarm. So when you double click on MDKarm enter this directory you will find a project for kymacovision. So the project is named uvprojects. So double click on this DMM underscore flash to RAM. dot uvprojects and that will open kymacovision5. From the explorer window I'm going to go to MDKarm directory and then click on DMM underscore flash to RAM. dot uvprojects. So double click on it and that will open kymacovision5. So if we open main.c we're going to look for the function mx underscore dma underscore init. So this is the function that will initialize the DMA and look at the different parameters as you can see this is exactly the same configuration in cube mx that we saw before. So this project was generated you know from the IUC file that we checked just before and then we just need to add the application code on top of it. I'm going to expand this open main.c scroll down and look for the function that is mx dma init. So as you can see the configuration is exactly the same as in stm32 cube mx. So dma1 channel 1 memory to memory the incrementation for both you know the peripheral and the memory so the destination and the source the world transfers worldwide dma normal priority low then also the interrupt for the dma channel 1 dma1 channel 1 has been enabled we're going to build the project like we do we know how to do it now using this icon and then once the code is built we're going to enter the debug session with the D we're going to build the project so pressing on the build or f7 once it's built let's enter debug session so with the icon D start debug session or control f5 we can now add 2 variables to the watch windows so to do this first look for this variable which is the source buffer so this is the buffer that will be located in flash so this is called a s r c so source constants so c o n s t underscore buffer so this is going to be located in the flash so what we're going to do is once you find the declaration of this buffer so it should be at the beginning of the file like around line 51 what you want to do is double click on the name right click and then add you know this variable to the watch one window then we're going to do the same thing with the destination buffer so a d s t underscore buffer so this is the buffer that will be located in the RAM basically and we're going to transfer this buffer to this buffer using the DMA so please add also a d s t underscore buffer to the same you know watch one window so we're going to monitor these two variables during the execution of the code now let's add the two variables so this is the first one right there you see around line 51 for me so for the version that I have so select the name right click then add to watch one window now it's added here same thing for the destination buffer so we're going to add it also okay and it's here as you can see now our two buffers are in the watch one window now we're going to add two breakpoints in main.c so the first breakpoints we're going to add so to add the breakpoints you will go to the line where you want you know to add the breakpoints go to the column right here and just click with your mouse that will add you know like a red dot like this so that's adding a breakpoints in kind micro region 5 so once so we're going to add one here so this is just before starting the DMA transfer the second one will be right when you know the transfer has been complete so we're going to look for this you know a test right there and in you know the line transfer complete detected equal 0 so that's where we re-initialise the variable that was set to say that the transfer was complete which was set in the interrupt you know of the DMA1 channel 1 so let's scroll down in main.c so right before starting the DMA transfer so this is a function that will start the DMA transfer so this says that you know this is for DMA1 channel 1 this is the source so this is the basically the variable that we are watching here that is located in the flash and here the destination is the buffer that is located in the RAM ok so we're going to add a breakpoint right there so go to the column right here and then left click now we want to add another breakpoint so we go scroll down so once you know this is you know the transfer has been complete we're going to add another breakpoint right here so please add you know to the line above like around 161 you can add you know like a breakpoint right here so left click on the column next to the line number so if you want to know where transfer complete detected is set to 1 so you have to scroll down and look for this function that is transfer complete which is a callback function so called from the ISR of DMA1 channel 1 so here as you can see transfer complete detected equal 1 please now run the code so remember this icon to run our F5 so you're going to hit the first breakpoint so just before starting the transfer so just before now so when it hits this first breakpoint check the destination buffer you will see that it should be full of zero so it's initialized to zero so for now it's empty so check this we're going to check this now can run the code so press on run see it will hit the first breakpoints just before the transfer of the DMA we're going to verify that the destination buffer is empty okay so it's full of zero as we can see press run again so now the code is going to hit the second breakpoints and when it reach the second breakpoints what we should see is that the destination buffer will be filled by all the values from the source buffer now I'm going to continue the code until it reach the second breakpoints and as we can see now the destination buffer is filled with the same values as you know the source buffer so this is the source and this is the destination so we have done a transfer from flash to RAM so from this buffer located in flash to this buffer located in RAM using the DMA