Saltar al reproductorSaltar al contenido principal
  • hace 2 días
STM32 es una familia de circuitos integrados de microcontroladores de 32 bits de STMicroelectronics. Los chips STM32 se agrupan en series relacionadas que se basan en el mismo núcleo de procesador ARM de 32 bits, como Cortex-M33F, Cortex-M7F, Cortex-M4F, Cortex-M3, Cortex-M0 + o Cortex-M0

Categoría

📚
Aprendizaje
Transcripción
00:04We're going to start by creating a template of this cube so that we can then simulate the project
00:11Since the Microvision. A micro or STM32F103 will be chosen because it is the best
00:19It can be simulated. We created a template for this microcontroller with an LQFP enclosure and now we select
00:32The input and output pins we will be using are PA0, PA1, PA2, and PA3.
00:40PA4, PA5, PA6 and PA7 will be exit points and PA7 will be entrance points.
00:47To display the result using a 7-segment display, we will use the
00:52Outputs PB0, PB1, PB2, and PB3. We can visualize them here, and we need to make the input
01:10It has an internal pull-up resistor to properly capture the signal. We give it a
01:20We name the project, add only the necessary files, and the code is generated.
01:29With this, we would have the template ready and we can start working from the moment there is
01:33Microvision. As always, we perform some preliminary tasks to be able to simulate the project. We remove
01:42For optimizations, we used the simulator and reconfigured the parameters of the DLL file to be able to use
01:53The STM32103 microcontroller. It's good that we compile it to check that everything is working correctly, and besides, this will help me...
02:03to give the option of being able to work with
02:05IntelliSense. IntelliSense will then allow me to retrieve functions and variables without having to write them out completely.
02:17Okay, now inside the main function we're going to create a looping task that will be continuously running. That
02:26We're going to carry out this cyclical task in a
02:28The function, in a file, will be called user functions.c and this is where we will create all
02:35our functions that will implement our
02:38control task. This will be separate from the other files. And this will then be the file that Proteus will use.
02:47we will import.
02:50Here we would define the content of the cyclic task function that is later called from the domain. And well, this function will use
03:02Another function called delay provides a delay of approximately
03:07One millisecond. Well, it will depend on the parameter we include. And what this cyclic task will do is
03:17write to a specific output pin.
03:20As you can see, when it sends a GPIO signal, it doesn't know what should come next. If we
03:29We included user functions within the project, so when you give it control space,
03:34If I should be able to tell what we're typing through IntelliSense, however, we need to do something beforehand.
03:43Another action is to include the file
03:45main.h and as we can see, IntelliSense now autocompletes what I want to enter. For example, if I enter
03:54GPIO pin, then it shows me all the words that started with GPIO pin.
04:01Here I would call the delay function, although since it is not yet declared, it is defined, but not declared, because
04:11Then it gives me an error.
04:13What I need to do is include all these declarations, all these prototypes, in a file called userfunctions
04:24.h.
04:29So, using this same file, I copy it, rename it, and from here all I have to do is
04:38What to do is use the same header,
04:44Take the same header line of the functions, remove the block that contains the function definitions, and replace it with
04:51a semicolon at the end of the header line.
04:56It is recorded, and with this, all these functions declared in functionsuser.c could be used.
05:07I first need to include this file, both in main and in the functionsuser.c file itself.
05:13If I include it, you'll see that delay stops giving errors.
05:23The error will no longer appear.
05:32Another warning also appeared, as if indicating that it didn't like 0, so if we put gp on state, gp or pin
05:41state,
05:42Well then, it is indeed in the type of variable that accepts hold gp or write pin.
05:48I no longer have errors, it can now be compiled, it simulates, I extract what would be port A,
05:59And it would be seen that when the program is run, it does what it's supposed to do, which is simply to blink the
06:06pin 0 of port A.
06:11It has been seen that between Cube and Kale, we have quite a few possibilities to obtain a template, edit and simulate the
06:19program.
06:20This combination is quite advantageous.
06:22Now we're going to use this same method to retrieve it from Proteus.
06:27We then opened Proteus.
06:29What we need to do here is create a new project, give it any name, a simple one, for example,
06:39We accept and create a new firmware in which we will use a different microchip, not exactly the 103, but the
06:46401.
06:48Now, what we need to do is de-embed the files so that they appear as real files, not as embedded files.
06:58embedded within the project.
07:00Here the files appear and we see how the file that has been created corresponds exactly to what appears.
07:07on screen.
07:10It is in this folder, where the source files are located, that we will have to include some other files that correspond to
07:19the function library
07:21with which we will manage and initialize the input/output peripherals.
07:27And also the real-time clock, which we need to synchronize the port with the HPBI bus.
07:37Well, what we do here is copy the libraries we need, and we also copy the functions from user.c that have
07:45has been what we created in the previous moment, in the previous phase.
07:51Once we have them, the next step is to incorporate them as source files into our project.
07:59We incorporate the .c files and although it is not mandatory, it is advisable to also include the header files, simply to
08:07then to be able to see it more easily.
08:10It's not necessary, but it's advisable.
08:13And well, on this template we can call our function that implements the cyclic task.
08:26First, we would also need to include the header file that contains the prototype of this function and all the
08:34necessary.
08:38It compiles, a series of errors will appear, and we're going to see what these errors are.
08:42Well, the first thing that appears is that it can no longer find this file, it doesn't really need it.
08:48Okay, we'll just leave a comment so it doesn't get in the way.
08:52Well, here I have copied and pasted the function with the input and output configuration of the PA and PEB ports.
09:00And here we have to keep in mind that the inputs must be in pull-up resistance mode.
09:09Since this function will only be called when we want to simulate with Proteu, what we're going to do is...
09:15to be a conditional compilation.
09:17For this purpose, we define a specific term, for example, to simulate with proteu.
09:23And we say that if that's simulated, then compile this function, but if it's not defined, then
09:30then don't compile it.
09:32We can actually use this later to do other conditional compilations.
09:38For example, what we did about including or not including main.h, we can do depending on whether it is
09:43defined that term to simulate with proteu.
09:47So if it's defined, we'll perform some tasks, and if not, we'll include main.h.
09:53Well, if we compile, a lot of errors still appear.
09:57For example, he doesn't know what HAL GPO-GRADE-PIN is, and it's actually a function of
10:03The HAL library is not part of the standard library.
10:06So we see that to work with pins we have other functions here, for example, to write would be GPO-GRADE-BIT and
10:13to read then red.pin.
10:15So what we're going to do is rename this function so that if we're working with the
10:23standard library, which modifies the name, replacing HAL GPO-GRADE-PIN with GPO-REDE-INPUT-DATA.
10:35Errors keep appearing because we haven't included the header files with these standard library functions.
10:46These functions are included in this header file.
10:55And well, we'll also have to include this other one for the clock.
11:01Well, we're making fewer mistakes now.
11:03Here, he doesn't know what GPO-PIN0 is, and what we're going to do is go back to
11:10that the microvision...
11:18I copy, I paste...
11:22And now simply, well, the values ​​1, 2, 4, 8, etc.
11:29And this other one here, GPO-PIN-STED, which I could directly remove.
11:33Or, I'll go back to that microvision, see where it was defined...
11:41Coto-definition...
11:42And well, I'll paste, copy and paste again.
11:45And if not, I'll just remove it.
11:47That nothing would have happened either.
11:51Okay, I don't have any more errors.
11:53And here, well, from the schematic what I have to do is include a resistor and a relay...
12:00So that when port 0 is activated alternately, PIN0 of port A, some action is seen.
12:12I take a yellow LED.
12:14Well, I just connect them.
12:16And as for the resistance, well, I'll now decrease its value to, for example, 330.
12:23Oh, and I mustn't forget that in main I also have to make a call to the configuration file
12:28of the input-output ports.
12:30To avoid errors, well, I need to include the header line in the header file.
12:36of this function.
12:37And this function could already be called from main.
12:42I remove the void, add a semicolon, call the function, and execute it...
12:47And you can already see how he performs the assigned task.
12:52The task in a twenty-fifth.
12:55Thank you.
Comentarios

Recomendada