STM32 Print Function for Debugging

แชร์
ฝัง
  • เผยแพร่เมื่อ 19 ธ.ค. 2024

ความคิดเห็น • 65

  • @abdalrhmanmasalkhi6736
    @abdalrhmanmasalkhi6736 3 ปีที่แล้ว

    vsprintf is implemented inside the C standard library, and if you are not linking to the Libc or any lib that implement that function you can’t use it. It is seems to me that the environment that you are using just linking to any sort of lib that implement vsprintf. And Thank you for the good videos you are uploading, I have been struggled with DMA at the beginning but watching some of your videos, has really helped me. Keep the good work!

    • @abdalrhmanmasalkhi6736
      @abdalrhmanmasalkhi6736 3 ปีที่แล้ว +1

      also, you could use __builtin_va_list and __builtin_va_start directly without the need to include stdarg.h file since, usually, the va_list and va_start are just macros expended to already mentioned symbols.

  • @kevshouse
    @kevshouse 5 ปีที่แล้ว +1

    Please, demonstrate to everyone how you would rebuild this into separate .h and .c files. Your demonstration of a function such as this is extremely educational. A video taking a further step to show how one can efficiently reuse code elsewhere would empower many.

    • @EdwinFairchild
      @EdwinFairchild  5 ปีที่แล้ว +1

      I think my entire gpio driver series accomplishes that. Creating a reusable c and h file with abstracted code.

  • @MilanKarakas
    @MilanKarakas 5 ปีที่แล้ว +4

    Excellent stuff. Now I can print out something... similar to serial monitor in Arduino. Thanks!

  • @makegen405
    @makegen405 4 ปีที่แล้ว +1

    Your videos have really helped someone here... keep up nice work.

  • @stevenlee1726
    @stevenlee1726 5 ปีที่แล้ว +2

    For those who cannot view variable value in watch1 or cannot set breakpoint during debugging, please uncheck Download to Flash. Flash -> Configure Flash tools -> Debug -> Settings -> Download to Flash

  • @OndrejPopp
    @OndrejPopp ปีที่แล้ว

    28:15 Eddie bro, tx for the intel! Luckily these days cube mx automates most if not all of this. Still it is very educational to learn about the bare metal programming. Just one thing, at 28:15 in the printMsg implementation I noticed you declare char buff[80] outside the #ifdef, so when that's not active you still have some overhead on the stack reserving and releasing 80 chars you are doing nothing with. Just saying... Maybe you had first other stuff outside the #ifdef as well that depended on the buff, but then that got deleted which left buff dangling outside the #ifdef?

  • @yasirfaizahmed2003
    @yasirfaizahmed2003 4 ปีที่แล้ว

    I feel guilty for watching this for free, Thankyou soo much...

  • @dymastro788
    @dymastro788 3 ปีที่แล้ว

    This is awesome man! your tutorials are great! keep up the good work.

  • @jayakumar5576
    @jayakumar5576 ปีที่แล้ว

    Sir, I started to learn Stm32f070rb. I don't know that how to use printf in keil. If I use your static printf code in my code, will printf work?
    Or I want to do any settings?
    Note: I am using keilu vision 5. I generating LL driver code using stm MX cube.

  • @AS-zs7jw
    @AS-zs7jw 3 ปีที่แล้ว

    please show the practical connections also in your video, i have connected the st link v2 to stm32f103, i do not know the connections to use accessport? do i need to connect USART1 tx pin to my computer? please answer some one ?

    • @EdwinFairchild
      @EdwinFairchild  3 ปีที่แล้ว

      you need a serial to usb converter, the stlink does not bridge the pc with uart, it only does the programming.

    • @EdwinFairchild
      @EdwinFairchild  3 ปีที่แล้ว

      wait a minute i explained the connections in the beggning, what part of that confused you?

    • @AS-zs7jw
      @AS-zs7jw 3 ปีที่แล้ว

      @@EdwinFairchild ok, i got your point and today purchased a usb to serial converter. thanks

  • @pseudounknow5559
    @pseudounknow5559 3 ปีที่แล้ว

    Please can someone explain me how we can send a 8O bit long buffer to a 8bits Data register. I dont understand this part with the for loop :(

    • @pseudounknow5559
      @pseudounknow5559 3 ปีที่แล้ว +2

      Ok I think i know what is happening but i need a confirmation. We send an ASCII character which is encoded in 8 bits to the UART Data Register and wait until it has been well received and then we move to the next character in the message and we loop like this for ever. Please can someone confirm this ?

    • @EdwinFairchild
      @EdwinFairchild  3 ปีที่แล้ว

      @@pseudounknow5559 that is correct

  • @hunterahmedadel
    @hunterahmedadel 3 ปีที่แล้ว

    how did you know the value of your peripheral's clock?

    • @EdwinFairchild
      @EdwinFairchild  3 ปีที่แล้ว

      You can calculate the value given what you have programmed into the RCC register , if you haven't programmed it yourself then you can use CubeMX or cubeIDE to see the clock tree and the values at certain speeds

  • @skywalker778
    @skywalker778 4 ปีที่แล้ว

    My USART does not transmit anything, what could go wrong ?

    • @EdwinFairchild
      @EdwinFairchild  4 ปีที่แล้ว

      You're code for setting it up, is wrong or you didn't copy things here correctly etc... Could be hardware is wired wrong I mean it could be a lot of things so idk

    • @skywalker778
      @skywalker778 4 ปีที่แล้ว +1

      @@EdwinFairchild I found the issue, a really stupid one.... I didn't enable the clock for GPIOA

  • @usmanhaider8634
    @usmanhaider8634 4 ปีที่แล้ว

    how to send any kind of data using keil stm32 on uart like in arduino
    1)serial.print('x');//displays x on uart
    2) serial.print(x); //dislay value of x variablr
    3)serial.print("any string");//display string
    4)serial.print(fl);//display value stored in float variable
    how can we do it. plz help

    • @EdwinFairchild
      @EdwinFairchild  4 ปีที่แล้ว

      This entire video is about that .... Did you not learn anything?

    • @usmanhaider8634
      @usmanhaider8634 4 ปีที่แล้ว

      @@EdwinFairchild
      Excellent work. definitely learned a lot but I want to debug my project through uart like in Arduino.
      simply I want you to make a video on that.

    • @EdwinFairchild
      @EdwinFairchild  4 ปีที่แล้ว

      @@usmanhaider8634 that is what this video is about. I'm not sure why you don't see that

  • @deepakraj-si1nl
    @deepakraj-si1nl 5 ปีที่แล้ว +1

    thank you .its was very helpful

  • @convolution_talk_show
    @convolution_talk_show 2 ปีที่แล้ว

    guys I have a big problem and I would appreciate it if this community assist me. when I am trying to debug using st link v2 to my stm32f103c6t6 Mc it says error target not connected I have tried almost everything but to no help. is there something that I can do to fix this problem or is there another way I can debug my code on my mcu

    • @EdwinFairchild
      @EdwinFairchild  2 ปีที่แล้ว

      could be you have a bad or fake chip on the blue pill, very common issue

    • @convolution_talk_show
      @convolution_talk_show 2 ปีที่แล้ว

      @@EdwinFairchild ok thanks Eddie so what chip should be on the blue pill?

  • @igorying8548
    @igorying8548 3 ปีที่แล้ว

    Really useful lessons! Thanks!

  • @mhashimshahzad2823
    @mhashimshahzad2823 6 ปีที่แล้ว

    Hi, I am trying to use nucleo-64 board. It has a Usart2 connected to the st-link. Do think the process would be similar for this?

    • @EdwinFairchild
      @EdwinFairchild  6 ปีที่แล้ว

      yea definitely just remember to look at where the usart is connected, for example my usart 2 is connected to a different bus and has a different bus speed so the calculation for the baud rate uses that different bus speed. Use CubeMx to check that clock configuration

    • @mhashimshahzad2823
      @mhashimshahzad2823 6 ปีที่แล้ว

      @@EdwinFairchild hey man, thanks for the reply. It finally worked. I was having some problem figuring out the configuration settings as i have different micro-controller (stm32f030r8). I have 2 questions for you, how do i know the default clock settings for mcu (i mean where in data sheet or reference manual? ) i just tried a bunch of values and it turned out to be 8Mhz for APB1 bus. The CubeMx showed the default would be 48Mhz (It was using PLL), that was not right . This command worked for me (USART2->BRR = 8000000 / 9600;)
      Also on my print is going diagonally down instead of just skipping a line on the serial capture program.
      Otherwise it worked great, Thanks a lot. Keep it up ! I learn a lot from your videos, hope to see more videos from you on I2C, SPI and other peripherals !
      best!

    • @EdwinFairchild
      @EdwinFairchild  6 ปีที่แล้ว

      @@mhashimshahzad2823 if you look on page 99 of your exact Reference Manual, youll see the RCC Clock control register, and you see it has a reset value of Hex 83 which is = 1000 0011 which means bit 0 and bit 1 are set and that sets the (HSI) High speed internal oscillator on, all the other stuff like PLL is off by default. On page 90 you can see that HSI is 8Mhz

    • @EdwinFairchild
      @EdwinFairchild  6 ปีที่แล้ว

      @@mhashimshahzad2823 Always check the registers in the reference manual they always state the Reset Value / Default Value, sometimes its easy to assume everything is 00000 but its not always the case. Also depending on what IDE you use , and the start up code can change these values... for example when i enter debug on my board, then I press the reset button of the debug menu, then i step through my code, and the way my start up is configured it sets the clock to PLL at max speed, this code is no visible from my main because its in a different file.

    • @mhashimshahzad2823
      @mhashimshahzad2823 6 ปีที่แล้ว +1

      @@EdwinFairchild Wow Thanks I do understand now! thanks again for your prompt reply!,
      Cheers

  • @kunalsalvi8382
    @kunalsalvi8382 5 ปีที่แล้ว

    Hey dude! great stuff. How did you manage to have it run of 72MHz without having it configured to do so? you need to enable HSE and configure it, right?

    • @EdwinFairchild
      @EdwinFairchild  5 ปีที่แล้ว

      The keil start up file does it by default. If you your board in debug mode but a break point in the system init function you'll see it goes to 72MHz .... look around in the startup file. I forgot the exact name it says startup

    • @kunalsalvi8382
      @kunalsalvi8382 5 ปีที่แล้ว

      @@EdwinFairchild are you sure? I've used CooCox CoIDE and over there I had to do it manually. I've written all the peripheral libraries like uart and stuff, but when i ran your code given above it worked. So can you please debug this code and make a video about it and show the register: RCC -> CR and RCC -> CFGR values. I would really appreciate it. If you are busy with something can you please send me a pic of these registers? my email kunalsalvi63@gmail.com
      Again i thank you for replying and hope this won't be a burden.

    • @EdwinFairchild
      @EdwinFairchild  5 ปีที่แล้ว +1

      @@kunalsalvi8382 yeah every IDE does it different I am now using TrueStudio. Check out this post I wrote about changing the clock speed for Stm32L0 the process should be the simialr for Stm32F1 : www.edwinfairchild.com/2019/01/testing.html One thing I reccomend is get CubeMX not to use the hall but see the Clock settings. For example Make A CubeMX porject for stm32f1 then set the clock to whatever speed you want.. then you can see all the required setting like division factors and multiplication factors and then just do that yourself via the registers.. I will email you what I mean

    • @yasirfaizahmed2003
      @yasirfaizahmed2003 4 ปีที่แล้ว

      @@EdwinFairchild The file name is "system_stm32f10x.c(startup)"

  • @ajitem100
    @ajitem100 6 ปีที่แล้ว

    Did you use stm32f103c8t6 ?

  • @mr.sandman4782
    @mr.sandman4782 6 ปีที่แล้ว

    Can you do a whole video on string manipulation. I'm having a lot of trouble doing things like var to string and other stuff. thank you for the video

    • @EdwinFairchild
      @EdwinFairchild  6 ปีที่แล้ว

      man i completely forgot about this.... ill get to it if youre still having issues, but if you use the code above you dont need to do anything else because it works like a printf fcuntion

  • @luizazeredo5197
    @luizazeredo5197 4 ปีที่แล้ว

    Seus vídeos são ótimos, ajudou bastante em meu aprendizado com o stm32, muito obrigado, você já fez comunicação com os displays da nextion? Difícil achar bons conteúdos desse display com os microcontrolador stm32, grande abraço, (Brasil-BR)

    • @EdwinFairchild
      @EdwinFairchild  4 ปีที่แล้ว

      Nextion displays only require a UART connection , so any tutorial for Arduino using nextion will also apply to stm32

  • @athulsnair6498
    @athulsnair6498 6 ปีที่แล้ว

    Hey thanks for these tutorials This is the only tutorial I could find so far that uses direct register coding instead of HAL. I have a STM32F429ZI DISCO1 board Haven't started coding yet. I know since boards are different codes will be different too. But it's a starting point. One question, Have you posted a UART tutorial??

    • @EdwinFairchild
      @EdwinFairchild  6 ปีที่แล้ว

      Athul S Nair I have not done a UART yet, I was planning on doing it soon but I am quite busy . However from this video you can see how simple it is to set it up. Just confirm with your data sheet for any differences

    • @athulsnair6498
      @athulsnair6498 6 ปีที่แล้ว

      @@EdwinFairchild when you finish with you website please add it in video description

  • @SatyajitRoy2048
    @SatyajitRoy2048 4 ปีที่แล้ว

    Good video for beginners.

  • @ajitem100
    @ajitem100 6 ปีที่แล้ว +2

    Nice video sir

  • @last-zura8899
    @last-zura8899 ปีที่แล้ว

    Thank you

  • @lahirupamodya6188
    @lahirupamodya6188 5 ปีที่แล้ว

    thank you. it really helped.

  • @mazinfo3978
    @mazinfo3978 5 ปีที่แล้ว

    great videos

  • @lalitahuja2721
    @lalitahuja2721 4 ปีที่แล้ว

    "Excuse me I had 4 slices of pizza" Are you trying to copy thenewboston? Is he trying to copy thenewboston? Because if you are you did good :)

    • @EdwinFairchild
      @EdwinFairchild  4 ปีที่แล้ว +1

      Don't know what the new Boston is

    • @lalitahuja2721
      @lalitahuja2721 4 ปีที่แล้ว

      @@EdwinFairchild thenewboston it's the best ever coding channel on youtube in the software domain of course :p

    • @EdwinFairchild
      @EdwinFairchild  4 ปีที่แล้ว

      @@lalitahuja2721 what kind of coding? High level and web stuff I assume? And what did I do that they did?

    • @lalitahuja2721
      @lalitahuja2721 4 ปีที่แล้ว

      @@EdwinFairchild He used to do pretty much everything from web to app development. Your talking style is similar to his and I meant it in a good way.

    • @EdwinFairchild
      @EdwinFairchild  4 ปีที่แล้ว

      @@lalitahuja2721 hahaha ok thanks! I looked it up, he has a lot of videos for sure. I just try to sound how I normally talk and not be all proper because idk it doesnt come naturally. Someone once commented because I said "shit' or something and now their kids cant watch or he cant put the volume loud haha like in the real world at some point no one is going to tell them to go shit themselves or something , people are funny