STM32F407 microcontroller

Thread Starter

Djsarakar

Joined Jul 26, 2020
489
Hello team
I have came across the datasheet of STM32F407. I am stuck with timer/ counter section 2.2.21. There are the many counter given in the table. So when we need to generate interrupt for 1 ms. Which counter should we use and which page show information in the datasheet to configure required counter?
@MrChips
 

MrChips

Joined Oct 2, 2009
30,821
I warned you that an ARM MCU is 10 times more complex than a basic MCU.
The Reference Manual for STM32F407 is 1749 pages long.
The STM32F407 has 14 timers. You can use any one to generate 1ms interrupts.

I am not going to answer every question that you come up with. You will have to learn to read and follow the Reference Manual on your own. You get to that level of competence by starting off with a simple MCU such as MSP430G2553 and learn to read its Reference Manual which is 644 pages long.
 

jpanhalt

Joined Jan 18, 2008
11,087
My advice is the same. Start with something much simpler. You don't need a chip to test the code I posted. Just simulate it, which is all I did. If you change the source for TMR0, it will also act as a counter. Timers and counters are basically the same thing, depending on the source of the "clock" or count.

Have you done the first exercise most people do, which is to flash an LED? I mean in actual practice, not simulation.
 

Thread Starter

Djsarakar

Joined Jul 26, 2020
489
What device has your teacher recommended?
My teacher had suggested me stm32f407 microcontroller. I have to make project in final year. The project has not been decided yet but she said that in my project I have to use STM32 microcontroller so I have to practice it
 

jpanhalt

Joined Jan 18, 2008
11,087
I just checked on the STM32F407. That's a wonderful MCU, 32 bit, 168 MHz and a plethora of peripherals. Considering your recent thread on PIC 8-bit timers, I'd say you are jumping from learning to fly a kite to flying an F35 in combat (https://en.wikipedia.org/wiki/Lockheed_Martin_F-35_Lightning_II). Of course, learning to land it is more difficult than simply flying it in non-combat mode, so maybe your teacher assumes you won't need to land. o_O

If you decide to retreat a little, let me say that counters and timers are basically the same. The difference is whether the thing being counted is periodic or not. Also, and very important, they continue to operate during interrupts (at least PIC's do). That means that an 8-bit timer/counter can easily be used for counting 200,000 counts (18 bits) , just by counting the number of rollovers, multiplying by 256 and adding to the final number.

The F35 is a great airplane. Have fun.
 
Hello team
I have came across the datasheet of STM32F407. I am stuck with timer/ counter section 2.2.21. There are the many counter given in the table. So when we need to generate interrupt for 1 ms. Which counter should we use and which page show information in the datasheet to configure required counter?
@MrChips
Hi,
Don't worry about the complexity of the controller, you shall not use all the features in the first release. I do not suggest to start your learning with an outdated device (e.g. PIC). There are lot of simple examples available to learn the ARM controller.
The SysTick is designed for this purpose, but any of the timer can be used for it.
Good luck,
Gabor
 
Last edited:

trebla

Joined Jun 29, 2019
547
Gabor, i disagree with you about PIC's are outdated. Every MCU architecture have it's applications. If you want make simple standalone thermostat for example then 8-bit PIC will do very well, even with integrated hardware PID control. If you need heavy math, graphics or internet traffic task to do then you should better look to ARM or MIPS MCU-s or even CPU-s. I think it's best to learn use different MCU architectures, then you have better start point for new projects and you go more proficient faster. Like driving different cars get more driving experience for you and you are learning faster :)
And starting with simpler things helps you learn faster and with less frustration. I suggest starting from PIC16F1xxx series (with MPLABX MCC), then moving to PIC18 K or J series, AVR , PIC24, STM32 (with CubeIDE). Both Microchip and ST have good starting tutorials on their homepages, also are out there Udemy tutorials and of course, textbooks :)
 
Gabor, i disagree with you about PIC's are outdated. Every MCU architecture have it's applications. If you want make simple standalone thermostat for example then 8-bit PIC will do very well, even with integrated hardware PID control. If you need heavy math, graphics or internet traffic task to do then you should better look to ARM or MIPS MCU-s or even CPU-s. I think it's best to learn use different MCU architectures, then you have better start point for new projects and you go more proficient faster. Like driving different cars get more driving experience for you and you are learning faster :)
And starting with simpler things helps you learn faster and with less frustration. I suggest starting from PIC16F1xxx series (with MPLABX MCC), then moving to PIC18 K or J series, AVR , PIC24, STM32 (with CubeIDE). Both Microchip and ST have good starting tutorials on their homepages, also are out there Udemy tutorials and of course, textbooks :)
Hi Trebla,
The reason, why I stated that the PIC is obsoleted, is that the PIC family cannot be programmed in C for full complexity (e.g. stack limitation, resource limitation), but the ARM family can be.
Therefore the ARM platform can be used in wide range of application (low power - M0, medium performance - M3, high performance - M4 and extreme high performance - >1GHz) and the needed effort to change the platform is very low and lot of free or very cheap toolchain is available for it.
Note: I do not have a full information about the PIC family, therefore I may be wrong.
Gabor
 
What do you mean by "stack limitation."
There are some version of PIC, where the stack is limited for some (very limited - e.g. 1-2) function calls and it cannot be used for parameter transferring (if I read well). These controllers are not usable for C-programming (or only very limited way). Is it true?
 

jpanhalt

Joined Jan 18, 2008
11,087
Most modern PIC's allow access to the stack, including the enhanced mid-range 8-bit PIC's, like the 16F1829.

Microchip has fully endorsed programming in C. In fact, its recent tools make Assembly programming a bit more difficult.
 

MrChips

Joined Oct 2, 2009
30,821
The origin of the PIC architecture as a GP MCU was flawed from day one. It is instructional to examine the development of MCU hardware and how the design of the architecture was influenced.

The original concept of the PIC goes back to 1975 as a hardware I/O peripheral to the General Instrument CP1600 processor.
This was entirely driven by hardware requirements and PIC MCUs followed a minimalist design concept not unlike the RCA 1802 in 1973. There was no concept of stacks. Exception processing was implemented by context or bank switching.

Compare this with Motorola 68HC11 design in 1984 and Atmel AVR in 1996. By this time, hardware stack handling was the norm in any MCU. It is important to note that the design of the Atmel AVR was facilitated by software simulation and influenced by compiler design.

In other words, Microchip PIC design was hardware driven while Atmel AVR design was software driven. With due respect to Microchip, most of the limitations of the original PIC design have been eliminated in their more recent higher-end models.

The irony is that Atmel is now owned by Microchip.
 

jpanhalt

Joined Jan 18, 2008
11,087
Sure, but Microchip bought Atmel, not the other way around. Of course, that may mean Microchip recognized its design was destined for failure, but it was successful.
 
Top