 Hi, I'm Sean Prestridge, Senior Field Applications Engineer for IAR Systems, and I'd like to show you a little bit about the Embedded Workbench for ARM and how easy it is to get started with STM processors. You'll notice that when you start the Embedded Workbench for ARM, you see the Information Center, which has information for getting started, user guides, integrated solutions, which would be RTOSs and other middleware, tutorials, support, release notes, as well as my pages. I'm going to look at the example projects, and you can see that I've already downloaded the ones for ST. So what I'm going to do is I'm going to scroll down, and you can see that there's one for the Cortex-M4 from ST, I'm going to select this one, and what I have attached to my computer right now is an IAR branded STM32-F407 board. You can also use the STM32-F407 discovery boards that are available from ST, and you can get the software for these boards from ST's website. On the backside of the card from the discovery board is the location where you can download these example projects for that discovery board. But since I'm using the IAR branded board, I'm going to select this, and I'm going to use the LCD example. When I click this, it will ask me where I want to copy the example program. I'm going to leave it in the default folder, and I'm going to rearrange my workspace here a little bit easier so that you can see what's going on. Inside of the workspace window to the left, you'll notice that there are different build configurations. The first one is a flash debug, which means that it's a debug build configuration, and the linker configuration file will put it into flash. There's also an SRAM debug where I can put it into the SRAM of the device. So you can create as many different build configurations as you want by clicking Project, and then going to Edit Configurations. So I can create a new build configuration, and I can also base it on one of my existing build configurations, or do it completely from scratch. If I do it on an existing build configuration, then it will copy everything that is available from that build configuration, and then maintain that build configuration completely separately from the other ones that I have. But for right now, I'm going to leave it as flash debug. You can see that there are folders inside of here, which are what we refer to as groups, and it's a logical way to keep your code separated from one another. You can drag and drop code into and out of the different groups as much as you want, and it's a convenient way to be able to organize your code as well as to control things like optimizations. So if I right click on a group and choose Options, I can either exclude this from build, or I can change the different options that are available for this particular group of files. So let's take a look at a couple of other project options. In order to look at the options for the entire project, I need to click on the overall project, and then right click and choose Options. You'll notice that under Debugger, by default it has JLink JTrace, but I have an iJet selected, so I'm going to click that. But also, if you're using the Discovery board, there's the ST link, so you would want to choose the ST link. But since I have the iJet, I'm going to select this. So once I click OK, I'm ready to download and debug my code. So when I click Download and Debug, it will start compiling all the code, including all the code for the STM32 Standard Peripheral Library. Once it's compiled this code, it will only do the ones that it needs to in order to be able to complete the build. So now that I have this running, you can see that there are a few windows that pop up. So what I'm going to do is rearrange my workspace a little bit, so that you can see what's going on. So for example, you'll notice that there's a green arrow over here on the source code. If I click over in the disassembly, you'll notice that the green arrow moves over here. And what this does is if I single step, it's going to single step at the disassembly level. So you can click back over in the source code window if I single step, it's going to single step at the source code level. So you can switch back and forth between these two different views to be able to single step at whichever one is most appropriate to you. Additionally, if you need to see the registers, you can click View, Register. And if I want to, I can also dock this view by clicking and dragging inside of my disassembly window so that it makes it a little bit easier to save screen real estate. Under the CPU registers, you can see that there are quite a few different classifications of registers. So you can find the ones that are most important to you. So I can allow the code to run just by clicking the Go button. And then I can halt to see exactly where I am. So that's a very quick way that we can do get up and running with the embedded work bench with the STM32F4 processor. But let's take a look at a few different things. I'm going to terminate the debugger and I'm going to look inside of main. And if I scroll down towards the end of main, you can see that there's a while loop and I can stay inside of this while loop while it turns on the LCD and it does various things. So what I'm going to do is I'm going to create a variable inside of here. And I'm going to make it static so that it forces the compiler to actually assign a address to it. So I'm going to make it a static integer loop counter and I'm going to initialize it to zero. And inside of this while loop, I'm going to increment the loop counter each time it comes through here. So now I'm ready to recompile and download and debug. And this will take just a few seconds for it to download. Once it downloads, I'm ready to start executing code. But I'm going to skip down here and what I can do is I can set a breakpoint inside of my code. If I right click, I can choose to toggle a code breakpoint. You'll notice that there are several other kinds of breakpoints. I'm going to hit on a few of the more popular ones here in just a few minutes. But I'm going to toggle a code breakpoint. So if I let this start up, you'll see that the LCD displays. And then I very quickly hit this breakpoint. You can see that the loop counter is currently zero. But this is a very simple breakpoint. We can also do what are called complex breakpoints. So if I click View and I choose breakpoints, again, I'm going to dock this inside of here so that I have a little more screen real estate. What I can do is I can edit this breakpoint type. And when I edit this breakpoint type, let's say I'm interested in only every tenth time it hits this breakpoint. I can set my skip count to 10. And you'll notice that when I do this, it tells me what the condition is and how many are left. And if I start executing, you'll see that it counts down about once per second until that timer expires. And you can see that now my loop counter is 11 because it hit it once first. And then I set the skip count. So there are other conditions that you can do with your breakpoint. So if I edit this again, I'm going to set my skip count back to zero. And I'm going to make a conditional expression here that says loop counter is greater than or equal to 30 as my condition. And I can choose whether the condition is true or changed, but I'm just going to leave that as condition true and click OK. And if I start executing again, it will execute for a few seconds until I look at my loop counter and my loop counter is 30. So that's a very simple way to be able to do the complex breakpoints that we have available. But let me show you another type of breakpoint here. What I'm going to do is highlight this and right click and delete that particular breakpoint. I'm going to show you what a data breakpoint does. So a data breakpoint can allow me to halt if that memory address is either read from or written to. And if I go to edit, I can choose the access type of being read write or just simply read or write. I can also make it only halt if it matches a certain value with a particular bit mask. So what I can do with this is I can start executing. And you can see that from the disassembly, I'll expand this just a little bit. You can see that it reads from it in the instruction before, but because of the pipelining of the architecture, it's the program counter is going to be pointing one ahead of the instruction where this was actually read from. So these are very simple ways to be able to utilize the data breakpoints. Now the usefulness of a data breakpoint is that if you have a certain data section that's being clobbered inside of your code, then you can set a data breakpoint on this and you can execute and see where in the code you are when your data is getting clobbered. This makes a very handy way to be able to tell exactly what's going on inside of your source code. So this is a very quick overview of what you can do with the embedded workbench and some of the powerful facilities that you get with the STM32 device as well as an iJet debugger. And again, you can use an ST debugger on the STM32 F-407 discovery board as well. You just need to remember to change the debugger setting in Project Options Debugger Setup. Thank you for watching this video and I hope you found it informative.