

- How to use non volatile variable in keil mdk arm how to#
- How to use non volatile variable in keil mdk arm generator#
- How to use non volatile variable in keil mdk arm code#
First, the TIMER channel is assigned to the TIMER structure. The TIMER configuration is somewhat complex.

Lastly, the TIMER2 global interrupt is activated with the highest priority. The statement, GPIO_PinAFConfig(GPIOA, GPIO_PinSource1, GPIO_AF_2), assigns GPIOA pin#1 AF (which is assigned to the TIMER2). For this project, we’re using GPIOA pin#1 in conjunction with the TIMER2. The pin AF can be found in the microcontroller’s datasheet. AF means the pin is neither input nor output - its function alternates depending on if assigned to the DMA, TIMER, RCC, or CCP, and so on. The pin is pulled up and the last pin mode should be set to the alternate function (AF). The GPIO-A1 is then selected, with the speed set to 50MHz. Next, the GPIO port-A clock must be enabled and the GPIO structure parameters should be defined. TIMER2 is connected to the Advanced peripheral bus1. We’ll import two structures for this configuration (GPIO and NVIC non-volatile vector interrupt). The STM32 libraries are in the form of structures. Instead of counting the external signal, we’ll use the internal clock, counting between the two rising edges of the external signal.įirst, you’ll need to configure the input pin and connect it to the timer. The is similar to the external signal counter method with a slight alteration.

We’ll use STM32 TIMER2 to record the number of counts (by using the counter) from the internal clock between the two rising edges of the external signal.
How to use non volatile variable in keil mdk arm code#
We’ll debug the code using Keil’s µVision IDE and view the real-time results on the IDE simulator.
How to use non volatile variable in keil mdk arm generator#
You’ll require an external frequency generator for this project. It’s possible to use them but, ideally, the signal should be the same tolerance level as the operating microcontroller. Some of the STM32 input/output pins are up to 5 volts tolerant. This means any external signal that’s greater than 3.3v must be decreased to match the microcontroller. of counts / 10.įor this project, we’ll use the STM32F0 discovery board, which is 3.3 volts tolerant. However, if we increase the time (say, to 10 seconds), then the frequency = n. The frequency can be obtained by dividing the number of counts by the time. This method involves running a counter on the external frequency signal to detect the number of positive edges within a fixed amount of time. However, this is not an easy task for a do-it-yourself project.Ģ. At each rising edge, you’ll need to take a timestamp to figure out the exact time period in between (1 / time period is the frequency). The simplest way to carry out this method is to detect the two rising edges of a frequency wave. Two of the most common methods for measuring the frequency of an external frequency using microcontrollers are:ġ. So, for this project to be a success, we’ll need to interface multiple microcontroller peripherals before we can sufficiently measure the frequency of an external signal. Unfortunately, microcontrollers are not equipped with frequency-measurement functions.
How to use non volatile variable in keil mdk arm how to#
In this tutorial, we’ll learn how to measure frequency by using microcontrollers.
