 Okay, so we have zero errors. We did get a couple of warnings there about a routine, an error handling routine that is declared implicitly, but it's not a problem. Hopefully we don't hit the error routine. So we now download the project into our board, and we now reset our board. When we connect our board to the PC using the micro USB now, Windows recognizes that there is a drive present. So if I go down to my G drive again, I have now got the FAT FS OK file has appeared on my hard disk. So this is now visible to say that the file system is running OK on the board. So that's what we have, and if I open that text file, it should say FAT FS is working properly. Open that with Notepad. So it's now generated a file to say FAT FS is working properly. So now we have the green LED on is to say that the mutex is in the app task and the green LED goes off when it switches the tasks and red LED on is to do with the USB task and off is to do with the mutexes. So as I plug and unplug the micro USB, you should see the changes as the mutex get passed between the different tasks that we've now got in the application. OK, so that's step three done now into step number four. So we're now going to add the audio codec to the system. So we're now going to use the SEI peripheral and the I2C peripheral so that we can control and transmit the audio out to the codec and then out via our headphones as well. So this is the schematic diagram for our audio codec. So we need to configure I2C and SEI on the various pins highlighted on the left-hand side of the screen. So if we go back to our cube environment we need to go back to the pinout diagram and add the I2C to PB6 and PB7. So back to our cube environment and we need to go on to the pinout diagram and it's I2C number one we're adding and we want to add the I2C peripheral and up here at the top at PB6 and PB7 we've got the two I2C pins. So I2C is now configured correctly. Now we need to configure the SEI. So SEI1, SEIA is the peripheral we need and then we need it to be master with master clock out. So therefore we should get based on our schematic diagram from Discovery board, PE2, 3, 4, 5 and 6 should get assigned when we select the SEI. So if we go back to our pinout diagram in cube so it's SEI number one, SEIA and we want to be master with master clock out. So there we can see that PE2, 4, 5 and 6 have been assigned but PE3 has not. Been assigned automatically. So that so these is what we've seen on our diagram. So we need to assign PE3 manually now. So we need to go through the configuration again of assigning a GPIO pin. So we left click to select PE3 to be a GPIO output. Then we right click to edit the user label and we have to make it match the pre-written code that we've got that we will paste into our application. So we have to make sure it's label becomes audio reset. So if we go back to our pinout diagram so we left click to be a GPIO output. Now we right click to enter a user label and it's audio underscore reset all in uppercase. So that's now assigned that pin to be a GPIO output. So our pinout diagram should now look like that. We have inside our cuba-mechs tool. So once the pinout diagram is correct we now need to go and configure the SAI peripheral. Now if we look at the serous logic data sheet which is the audio code that we have attached on our discovery board and we look at the information from the encoding of our .wav file we will find the frequency of our wav file is 44.1 kilohertz. Therefore we need a clock for the SAI of 11.2896. So we need to now go and configure our clock tree. So the SAI number one will send out as close to 11.2896 as we can get. So we will get hopefully 11.29411. And then we have to make sure that SAI one PLL is selected to come through to the SAI one peripheral. So if we go to our clock tree in the cube environment. So we go down here to SAI number one. So we now need to change our PLL configuration here to be 48 on the multiplier. As you've noticed the USB is no longer happy so we need to make sure that we divide that by four to correct our USB of 48 megahertz. And we need to make sure the divide for our SAI peripheral is divided by 17. So this means our multiplexer for our SAI one clock is now 11.29411 which is close enough for what we need for the Syrra logic chip. So you should have your I squared C clock one at 80 megahertz and your SAI one at 11.294118. Just to confirm it, I squared C is 80 and SAI one is 11.294118. So our clock is now correct for our audio codec. Now we need to go and configure the I squared C so that we can set the control registers correctly for the audio codec. And we need some information from our audio codec data sheets again. So our clock frequency is 100 kilohertz and our rise time needs to be a maximum of one and our fall time needs to be somewhere less than 300 nanoseconds. So we need to make sure our rise time is below one so we're selecting 640 and our fall time has to be below 300 so we're selecting 20 on this. So if we go back to our cube environment we now want to configure our I squared C. So standard mode means 100 kilohertz. So therefore our rise time needed to be 640 and our fall time needed to be 20. So that's our I squared C configured. Next we need to configure the serial audio interface. Now the serial audio interface has a lot of parameters that need to be configured to match our audio file and how we're formatting the audio file. So here are all the parameters that need to be edited based on the structure of the file and the encoding of the file. So there's a lot of parameters to change here. So we have the frame length, data size, the synchronization length, the frame offset, the number of slots we're using, the synchronization definition, the selection of the slots, the audio frequency, the clock strobing, the FIFO threshold and the output drive. So all of these parameters need to be set inside the configuration of the SAI peripheral. So if we go through that step by step, so I'll go back to cube into my SAI peripheral and go into the parameter settings. So our parameters for the SAI, so we have a frame length of 32 bits. Our data size is 16 bits. So we have 16 bits for left and then 16 bits for right audio. So we've got stereo audio coming in. The synchro active length level needs to be set to 16. Oops, 16. The frame synchro offset needs to be selected to before first bit. So we're synchronizing before the first bit. The number of slots needs to be selected to two. So we have a left slot and a right slot. Slot active needs to be on user settings so that we can tick slots one and slots two. Our audio frequency needs to be 44.1 kilohertz. Our clock strobing needs to be rising edge. Our FIFO threshold needs to be one quarter full and our output drive needs to be enabled. So hopefully I've selected everything correctly there. So just check frame length of 32, data size of 16, a frame synchro active level length of 16, a synchro offset of before first bit, number of slots to be set to two, slot active to be user settings and then slot zero and slot one selected, an audio frequency of 44.1 kilohertz, clock strobing to be rising edge, FIFO to be one quarter full and output drive to be enabled. So that's correct. So we can locate that screen. So this is our configuration. So our audio track is 58 seconds long. It's 16 bits per second as a bit rate with a frequency of 44.1 kilohertz. So therefore we're only using 22.68 microseconds. So our 80 megahertz device is far, far faster than our audio. So there's plenty of time for us to transmit our audio out. So we can run our audio quite nicely. So to make sure that we don't get any interruptions in our audio, we're going to use a dual buffer with the DMA so that while our audio is streaming from one of the buffers, then the file system can be filling the other buffer with the next stretch of information so that we get a seamless transfer of data out through our headphones. So we now need to go and configure the DMA to do this in the SAI configuration. So there's a lot of parameters there again that we need to go through. So we'll go through that step by step directly in the cube MX environment. So if we go back into our SAI peripheral and go into the DMA settings. So the first step is to add a DMA channel. So I am going to select the SAI A channel. The channel we're using is DMA 2 channel 1 which is correct by default. The direction needs to be memory to peripheral. So we're streaming it from the memory out to the peripheral. The priority needs to be set to high so we don't get any interruptions in our audio stream. We need to make sure that the memory address is incrementing so that it fills the buffer quite nicely. Our mode is circular. So we're going to go round the same buffer over and over again. And our data width is half word. So we need to change our peripheral end and our memory end to be half word for both of those. So then we can apply an okay that. So that's our DMA configured for our SAI peripheral. So now we've got to add this new task to our RTOS. So we now need to go into the configuration of the RTOS and add a new task to our system. So it's going to be called the audio task. Its priority is going to be normal. We're going to have a stack size of 1024 and our entry function is audio task body. So if we go back to our cube and into our free RTOS configuration we need to go to the tasks and cues tab. And we now need to add this new task. So it was called audio task with a capital T in task. Priority is normal. The stack size needs to be 1024 and our entry function is audio task body with a capital T in task and a capital B in body. So then we can okay that and we should now have three tasks in our RTOS available to us. So we should have now three completed tasks set up inside our RTOS. So that we can use these two buffers we need now need to add some constants into our RTOS so that we can use these two buffers that we're creating. So we now need to go into the user constants tab and add some constants to our free RTOS process. So we'll have constant A, capital A at value zero X one and constant B at value zero X two. Let's go back to our cube environment and go into user constants. We need to add constant A at zero X one. Okay, and then we need to add constant B at zero X two and we have our two constants. So that's what we have now. So we've got our two constants sat inside our free RTOS. So that's all we need to do now. So we now need to build the project again but again do not open the project until we've done the patch to add the code across. This time we've got five files to add. So there's one missing here in the source. So there's an SAI.C file as well. We have the map file of the codec so we know what's going on for the structure of the serious logic codec. We have the modifications to the freeRTOS.C to cope with this new task and these two new constants we've just added. And then we have the I squared C files and the SAI files. So what's inside the I squared C files? It's all the audio control settings for initialize, play, pause, resume and stop. And same to do with all the set volumes and set frequencies as well. So all these files have now been populated inside the I squared C.C template that will be generated by the cube environment. So we need to go to our section two putting it all together, patch for step number four this time and we need to copy across all these five files that you find in the ink and source folders. So if I go back to my cube environment, I'll okay that, I'll generate my code, still get the warning about the SysTick. So say yes again, generating my environment. So I don't want to open the environment so I'll say close because I now need to go and do the patch of the files first. So I now need to go and find my files during number two, patch, step four, audio. So the include ones there are two, copy them across, paste them into there. One of them will be only overwriting. And in the source, there are three of them and we copy those into our source files and paste all those in there. So now we're ready to launch the application. So we go into the eWarm and launch the project EWW.