#7 ARM Microcontroller Tutorial - Changing the Clock to 48Mhz Using the GNU Library

Поделиться
HTML-код
  • Опубликовано: 5 авг 2024
  • Purchase my new book: Arm Microcontroller Programming and Circuit Building Volume 1
    amzn.to/3LFRaU5
    My Patreon Page if you would like to help support this channel and keep this content going.
    / newbiehack
    This video is a video I had on Patreon for paid members, but I wanted to release this video now so I can show you how I changed the clock speed to 48Mhz. I am still working on the implementation using the STM32CubeIDE.
    Links to the software:
    STM32CubeIDE: www.st.com/en/development-too...
    STM Studio: www.st.com/en/development-too...
    STM32CubeMonitor: www.st.com/en/development-too...
    Parts you will need in your prototyping environment:
    Kits to get you up to speed quickly:
    newbiehack.com/Categories/ARM
    If you already have the microcontroller, here are some breakout boards to use:
    64 pin - amzn.to/3rUXeiq
    48 pin and others - amzn.to/3IVkC6D
    STM-Link V2 Programmer:
    newbiehack.com/categories/new...
    amzn.to/3IIZlgj
    Prototyping Breadboards:
    newbiehack.com/categories/new...
    amzn.to/3o2Nh1g
    Resistor Assortment Kit:
    amzn.to/3H4R3ii
    Solid core hook-up wire 22 AWG:
    amzn.to/3IDGinA
    amzn.to/3g5TKUJ
    LEDs and Displays:
    newbiehack.com/Categories/LCD...
    amzn.to/3Az1zf7
    Trimmer potentiometers:
    newbiehack.com/Categories/Pot...
    amzn.to/3H6q067
    The Dynamixel servo I will be using in the USART videos:
    amzn.to/35s3qHl
    Microfarad Capacitor Assortment:
    amzn.to/32BIX1G
    Capacitors on Newbiehack.com:
    newbiehack.com/Categories/cap...
    Electrolytic Capacitor Assortment:
    amzn.to/33TtLxt
    The cheap oscilloscope that I use (because it's cheap and will work all of the projects in these tutorials): amzn.to/2rSHnBa
    A better oscilloscope and the one I would recommend: amzn.to/2qizK5M
    The brand of the multimeter that I use and the one I recommend: amzn.to/2qicUez
  • НаукаНаука

Комментарии • 41

  • @PatrickHoodDaniel
    @PatrickHoodDaniel  2 года назад

    If you want to attempt this code in your project, make sure to use the STM Link utility to erase the chip. I did notice in this video that I powered the ADC power pins. I'm not sure if that will affect the current implementation that I am working on, but I may give it a try.

    • @kevinhoublon8630
      @kevinhoublon8630 Год назад +1

      Hello, great video 😄.
      I'm a beginner and I have a few questions :
      1 : Can we control the following components with your microcontroller :
      - 1.1 : A stepper motor
      - 1.2 : dc motor
      - 1.3 :color sensor
      - 1.4 : a linear actuator (which can be controlled by a l293d like some dc motor to change the sens of the rotation, or in the cas of an actuator, the direction of the translation)
      - 1.5 : an infrared sensor (IR Sensor)
      - 1.6 : a servomotor
      - 1.7 : a pump
      - 1.8 : a water level sensor
      2 : If so :
      - 2.1 : do you have these references of theses elements which works with your microcontroller?
      - 2.2 : For each components, do you have examples which show how to program them?
      3 : I wish to make a PCB but I don't want to weld your microcontroller because I would like to reuse it.
      I want to insert the microcontroller into an intermediate piece then I will solder the intermediary piece on the pcb board.
      Is there an adaptor I can use as an intermediate piece? Do you have the references? A link to buy it?
      Thank you in advance for your precious help.
      Best regards.

  • @hanspeterbestandig2054
    @hanspeterbestandig2054 2 года назад +2

    Great video! Very well explained! 😀 Thank you!
    However I still have a note to consider. As commented in your previous Video by me I still wonder that your CPU runs with 48 Mhz from the Flash without telling the Flash controller not to insert some (at least 2 in your case) Wait states. That is because fetching the Instructions/data from Flash (and your Program Runs out from Flash Memory?) needs to take care not to violate its access time.
    This minimum time is usually mentioned in the Controllers Datasheet AC Characteristics section... Since the minimum access time for Flashes of these kind of STM 32 chips is usually around 50 ns (which means 20 MHz) you‘ll _usually_ tell the Flash controller to insert wait states in order to slow the CPU down by performing wait states when it fetches instructions/ data from this slightly slow memory...
    I‘m telling this because I had some interesting issues that caused my program randomly after I increased the core frequency as you did and did not honored this essential aspect... ;-)
    Interesting side note: Renesas invented some slightly faster Flash technology that allows their uC to execute code at 100 MHz (10 ns!) without the need to insert any wait state....
    ...so I had a peek into the reference manual of the STM32F030 (this is the one you are using in your Project?) (www.st.com/resource/en/reference_manual/rm0360-stm32f030x4x6x8xc-and-stm32f070x6xb-advanced-armbased-32bit-mcus-stmicroelectronics.pdf)
    Here at page 58 - the Issue "Flash access control register (FLASH_ACR)") - for the LATENCY bits ST states: "One wait state, if 24 MHz < SYSCLK ≤ 48 MHz".
    IMO that it runs on your hardware is luck but to be safe the Latency needs to be adjusted to a value of 1

    • @PatrickHoodDaniel
      @PatrickHoodDaniel  2 года назад

      Very cool. I will take a look at this and mention this in a future video to look at this comment. Thank you for mentioning this.

  • @Jose-tw9bl
    @Jose-tw9bl 2 года назад +1

    Great content!

  • @kayakMike1000
    @kayakMike1000 2 года назад +1

    I recall the complexities on the LPC1769. The core starts off on the internal oscillator, but the xtal oscillator can feed into a PLL which feeds into the core clicks... And you gotta wait for a lock on the Xtal...

    • @PatrickHoodDaniel
      @PatrickHoodDaniel  2 года назад

      That's really interesting. There are probably many commonalities with these microcontrollers.

  • @waymamma
    @waymamma 2 года назад +2

    Nice video, very clear and thorough. You did neglect to set the TIM1 timer's clock source which is important. Apparently for your MCU the defaults were OK, but since you've taken the time to set other STM32 registers to their defaults you should also set the TIMx clock source as well.
    I'm going to stop bothering you now :)

    • @PatrickHoodDaniel
      @PatrickHoodDaniel  2 года назад

      Haha. Yes, I know. Thanks for that. In my video where I hopefully get things right, I will add that important piece of information.

    • @PatrickHoodDaniel
      @PatrickHoodDaniel  2 года назад

      No need to stop bothering me. You are giving me great information and the RUclips gods like comments.

  • @kevinhoublon8630
    @kevinhoublon8630 Год назад +1

    Hello, great video 😄.
    I'm a beginner and I have a few questions :
    1 : Can we control the following components with your microcontroller :
    - 1.1 : A stepper motor
    - 1.2 : dc motor
    - 1.3 :color sensor
    - 1.4 : a linear actuator (which can be controlled by a l293d like some dc motor to change the sens of the rotation, or in the cas of an actuator, the direction of the translation)
    - 1.5 : an infrared sensor (IR Sensor)
    - 1.6 : a servomotor
    - 1.7 : a pump
    - 1.8 : a water level sensor
    2 : If so :
    - 2.1 : do you have these references of theses elements which works with your microcontroller?
    - 2.2 : For each components, do you have examples which show how to program them?
    3 : I wish to make a PCB but I don't want to weld your microcontroller because I would like to reuse it.
    I want to insert the microcontroller into an intermediate piece then I will solder the intermediary piece on the pcb board.
    Is there an adaptor I can use as an intermediate piece? Do you have the references? A link to buy it?
    Thank you in advance for your precious help.
    Best regards.

    • @PatrickHoodDaniel
      @PatrickHoodDaniel  Год назад +1

      Yes, you can control all of the items on the list. The motors will need a device in the middle to drive the higher powered coils of the motor, but the uC can control the these drivers. The sensors can be connected directly as per the application notes of the sensors.

    • @kevinhoublon8630
      @kevinhoublon8630 Год назад

      @@PatrickHoodDaniel Hello, thank you very much for your feedback 😁.

  • @vovanikotin
    @vovanikotin 2 года назад +1

    Nice lesson!
    Some of your lessons I watch with my phone.
    Wanna ask you, can you littlebit zoom in firmware editor? Ctrl+mouse wheel should work.
    Thanks!

  • @aw805
    @aw805 2 года назад +1

    I really love your tutorial about avr.. but i wonder, could you make a video about self programming avr step by step? Because i couldn't find it on the internet. Thank you so much for your time.. 😁👍

    • @PatrickHoodDaniel
      @PatrickHoodDaniel  2 года назад +1

      Could you explain what you mean by self programming?

  • @mic03311
    @mic03311 2 года назад +2

    Thanks this is a great video! If I got it right you increase the frequency so that you can overcome the inaccuracy of the internal clock using majority voting technique. Why not use an external oscillator? They are not that difficult to integrate in a design? I am curious to understand. Thanks 👍

    • @PatrickHoodDaniel
      @PatrickHoodDaniel  2 года назад +1

      I may use an external oscillator. In fact I just did a small project that used it an external oscillator which worked fine. I will make a presentation at some point to show how to use an external oscillator, but I would like to give that option to you all. I personally want to try to get the internal oscillator solution to work so I don't have to add components to my final circuit.

  • @Nabilphysics
    @Nabilphysics 2 года назад +1

    Dear, this video is a big jump from ARM Microcontroller Tutorial #5. Could you please explain about stm32 clock for newbie like video #4 where you taught IO configuration.

    • @PatrickHoodDaniel
      @PatrickHoodDaniel  2 года назад +1

      As mentioned at the beginning of the video, this is a video from 4 years ago showing how I set the MCU to 48Mhz. I will be m making a video explaining all of this.

    • @Nabilphysics
      @Nabilphysics 2 года назад +1

      @@PatrickHoodDaniel Thank you very much for reply. Really appreciate it. Love and Respect from Sylhet, Bangladesh.

  • @FaysalAhammed-lj2eq
    @FaysalAhammed-lj2eq Год назад

    Can you arrange a video to configure Ethernet(ENC26J60/W5500 or other module) using LWIP library to facilitate tcp-ip communicaiton?

  • @embededfabrication4482
    @embededfabrication4482 2 года назад +1

    stlink speed and other settings to connect with STM32M0 ? The oem stlink can't find the target

    • @PatrickHoodDaniel
      @PatrickHoodDaniel  2 года назад

      Check out the previous video. I show how to erase the chip if you run into a problem.

    • @embededfabrication4482
      @embededfabrication4482 2 года назад

      @@PatrickHoodDaniel The STlink clone I got from you sees the target no problem though, I just can't update it. The chip must be ok then, I'll try it anyway.
      nope, it has to see the target in order to erase it.

  • @jugnu361
    @jugnu361 Год назад +1

    I come here to learn stm32

  • @varunkoganti9067
    @varunkoganti9067 2 года назад +1

    Please consider switching to vs code & cmake. These ides are phased out.

    • @PatrickHoodDaniel
      @PatrickHoodDaniel  2 года назад

      In this series, I am using STM32CubeIDE. Are you saying that the STM32CubeIDE is phased out in favor of vscode and cmake?

    • @varunkoganti9067
      @varunkoganti9067 2 года назад +1

      @@PatrickHoodDaniel I used the term "phased out" because well i use Nordic 52840, an esp32, avr, at89s805x, and stm32.
      Having each individual ide is difficult. It would be nice to have " one tool to use them all" :).
      Also I have been watching this channel for long time. And I think you should shift from stm32 to another mcu, stm32 is a good start to lean about arm architecture. Documentation is great. But they lack wireless features. Maybe an Nordic or any other cpu with wireless features (must be of arm architecture cause we are learning arm arch in this series)
      Switching to wireless features will cover both arm arch & also wireless stuff. This would be nice and intresting addition to this channel.

    • @PatrickHoodDaniel
      @PatrickHoodDaniel  2 года назад +1

      @@varunkoganti9067 I appreciate the suggestion. As you mentioned, this series is focused on the ARM architecture, but I will show code that is both register level and HAL based, so you will be able to use the code with the devices you listed. I will add wireless capabilities using external radios and possibly go into SOC options in the future. The IDE is not as relevant as the HAL option should be IDE agnostic.

    • @PatrickHoodDaniel
      @PatrickHoodDaniel  2 года назад

      @@varunkoganti9067 Additionally, when you use VSCode and cmake, what do you use to monitor variables in real time while the microcontroller is running? I tried searching for applications that would have this feature, like using jtag or something, but I found nothing.

    • @varunkoganti9067
      @varunkoganti9067 2 года назад +1

      @@PatrickHoodDaniel there is a plugin call "cortex-debug" by Marus. Guy deserves appreciation imo for creating this.
      This plugin is great.
      You can view global, local and static variables.
      You have access to variable watch window.
      You have a call stack to see how ARM app call stack procedure worked.
      Also cortex reg can be viewed.
      Only thing missing with cortex debug is the assembly view.