#3. How to Configure UART using REGISTERS || STM32F4

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

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

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

    When I applied it on stm32h7b3, it didn't work. But when I cleared the moder bits before assigning it, it worked. Thanks for no hal library explanation!

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

    8:46 Why we are using pa2 and pa3 ? how can I underdanst which pin use ?

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

      By checking the schematics of the board. Also check the pin description of the mcu to see which pins can be assigned to which peripheral

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

      @@ControllersTech thank you sir

  • @m-electronics5977
    @m-electronics5977 หลายเดือนก่อน

    15:43 I don't understand only that Special case: Is the carry 0d16 or 0d1? Because nothing of that makes sense in my head. Because 50,99 + 16 is not 51 and also 50,99 + 1 is not 51 ?
    Can you explain it please?

    • @ControllersTech
      @ControllersTech  หลายเดือนก่อน +1

      Suppose USARTDIV = 50.99
      We fiest multiply the decimal part with 16, so 16*.99 = 15.84
      The FRACTIONAL PART value can only be a number, and it is higher than 15, so the next possible value can be 16.
      Now remember that the FRACTIONAL PART is only 4 bit, so it can not be higher than 15. Therefore the difference (16-15=1) will be added to the MANTISSA and the FRACTIONAL PART becomes 0.
      This makes the value 51.0

    • @m-electronics5977
      @m-electronics5977 หลายเดือนก่อน

      @ Thanks. But that with the difference isn't weiteren in the reference manual. Maybe it is clear for people that use the Mantissa + Fraction longer / understand it completely

  • @m-electronics5977
    @m-electronics5977 หลายเดือนก่อน

    23:45 I think one moment: Why we can receive data that is longer than 8 bits, but we receive the data byte for byte😊

    • @ControllersTech
      @ControllersTech  หลายเดือนก่อน

      I don't understand what you want to ask

    • @m-electronics5977
      @m-electronics5977 หลายเดือนก่อน

      @ That was not a question, I wondered why we can receive multiple-byte length messages, but we receive one byte -> send it back -> receive the next byte -> send it back or?
      But then the Output in your serial monitor maybe must look like this:
      "h h e e l l o o ..."
      First char send you to the Microcontroller, second char comes back.
      Why it isn't so how I described?

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

    Thank you so much, what's the song that you are using in the background?

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

    I love your videos and want to thank you for what you are doing! you are great!

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

    i am using nucleo f446re board i used the same code of yours but i am not getting and data from uart2 pins (pin PA2) , i connected arduino and stm32f4 board .
    i am getting uart values in tera term terminals but not getting from pins of micro controllers
    do i have to do any setup in the board to get uart datas from pins.

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

      solved the problem by SB14,SB13 soldering removed and SB62,SB63 soldered then on board UART worked

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

      Yeah by default uart2 is connected to the usb for communication with PC. That's why i use other uarts for communicating with other devices

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

      Actually he was describing some other issue.
      You can't get the uart2 data from pins PA2 and PA3 in nucleo board. Uart2 is directly connected to the stlink usb.
      So he did those things to get data from those pins.

  • @ucontrolchannel5967
    @ucontrolchannel5967 4 ปีที่แล้ว +2

    great job again, waiting for I2C :)

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

    Really Excellent!!! Very well presented ! Thank you .

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

    Thank you so much for this useful video. I tried same program in stm32L072 but i am not getting any data. Then one more doubt I have in stm32L0 series, what is the alternate function value in stm32L0, In reference manual not there so I am asking you.

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

    Thank you so much. This series on stm32 || NO HAL is very educational and fun to watch/learn. One question on line 30 (and 31) where GPIOA->AFR[0] is written, but why not GPIOA->AFRL for more explicit expression per reference manual?

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

      AFRL is not a register in the core file.. it's AFR[0]

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

      the convention being used in the reference manual and the code are not the same. That's why the confusion occurs

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

    Thank you. Do you have a similar tutorial for Bluepill?

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

      The process is identical in bluepill also

  • @madayaswanth1205
    @madayaswanth1205 8 หลายเดือนก่อน

    from where u getting comments code

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

    you mentioned like writing 0x07 on AFRL7 for USART 1 to 3 but you are writing it on both AFRL6 and 7.i got stuck there lol,can you explain that

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

      I guess you mean at 12:05.
      I wrote 7 to the 8th position for AFRL2 ( pin PA2) and at 12th position AFRL3 (pin PA3)

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

      @@ControllersTech you're so great so humble thanks for replaying to my doubt i got cleared about that .Can you suggest which IDE is best for STM32 like IAR or systemworkbench by eclips or Keil.also i am working on SAMD21 thats so complext to understand do have any idea on that

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

    thank you a lot for this tuto, please i'm using stm32f429discovery board the register are slightly same as your i did all think correclty but did not get any char on the serial please can you guess what can be the issue

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

    Can u explain about the line in detail
    While(! (USART2->SR & (1

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

      It's the same

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

      Can you explain about that line what does it do step by step?

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

      It waits for the 6th bit in the USART_SR register to reset.

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

    If I connect an Xbee pro S1 module, what kind of changes do I have to make so that it receives data?

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

    USART2->CR1 &= ~(1

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

      yes, thats most right statement

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

    How can we glow led using usart2 ?

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

      watch the first video and implement it here

  • @Jishnu.Janardhanan
    @Jishnu.Janardhanan 4 ปีที่แล้ว

    Thank you for the video, I was looking for it. One question, in your opinion what is the best method to communicate with a GSM module like SIM800 by UART in a FreeRTOS design?

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

      Don't know how to handle that situation with freertos, but without freertos, you can use uart ring buffer to take care of it.

    • @Jishnu.Janardhanan
      @Jishnu.Janardhanan 4 ปีที่แล้ว

      @@ControllersTech Thanks for the reply.

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

      Yes. You can use UART and push AT commands.

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

    If I connect an HC-06 Bluetooth module, what kind of changes do I have to make so that it receives data?

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

    Excelente explicación, HAL lo hace todo más fácil, cuando pueda analice el bus CAN, gracias

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

    i did what you said in you video but still it is not working for me
    Please help me

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

    Hi...!
    I have coded everything right according to my stm32f407DISCOVERY Board. I am able to send string using Hercules, But not able to recieve and send it back. I am having a warning where as your does not. on this Line. Send_String(data); Wrning is "main.c(84): incompatible integer to pointer conversion passing 'uint8_t' (aka 'unsigned char') to parameter of type 'char *' [-Wint-conversion].

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

      1. Is this your first program with registers ? I would highly recommend that you see the first 2 videos and make those work first.
      2. You should use breakpoints at different stages in the code to check where it stucks or something.
      3. Also make sure the clock setup is right, and you haven't copied exactly what's mine.
      Different controllers work at different frequencies. The procedure would be same but values will be different.
      4. If doesn't work, contact me on telegram or discord.

  • @abhishekm1903
    @abhishekm1903 4 ปีที่แล้ว +3

    Brilliant work...!!!

  • @sharana.p6161
    @sharana.p6161 3 ปีที่แล้ว

    Thank you for the video. I'm struggling with lcd on 4-bit mode. But it works very fine in 8-bit mode. Do you have any lcd libraries for 8 bit mode

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

      Just modify that 4 bit library. In functions, send_cmd and send_data, Instead of sending the data in 2 parts (upper and lower nibble), send a single byte.
      Also modify the startup sequence as per the lcd datasheet (you need to remove 1 or 2 statements i guess).

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

    You even don't know how sad I become when I realized that your voice is synthesized (after watching more than a few of your videos), I felt like in a movie Her. Nonetheless, I really appreciate your work :)

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

      It's amazing that you realized it now.
      Synthesized version is a bit better, as it doesn't have accent issues. Also it's easier for youtube to generate the subtitles in all the languages.

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

      ​@@ControllersTech Haha, yes, actually my bf pointed it out and I was like - no way that that's not my fav stm32 youtuber voice 😂

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

    Not sure if someone knows why but I am using an STM32F767ZI which has slightly different registers and I was not able to get the baud rate I wanted. I debugged the issue and I noticed that despite having APB1 peripheral clocks at 54MHz it was capped at 20 MHz and when calculating the proper prescalar for that clock I was able to get the peripheral working.

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

      Whats the voltage scale range ?

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

      ​@@ControllersTech Sorry I am not too sure where to find that information but I found a section on the "Voltage Regulator" this in the datasheet on page 123.
      www.st.com/resource/en/reference_manual/dm00224583-stm32f76xxx-and-stm32f77xxx-advanced-armbased-32bit-mcus-stmicroelectronics.pdf
      I also found this on page 115 of this link
      www.st.com/resource/en/datasheet/stm32f765bg.pdf
      When the regulator is ON, the voltage scaling and over-drive mode are adjusted to fHCLK frequency as follows:
      - Scale 3 for fHCLK ≤ 144 MHz
      - Scale 2 for 144 MHz < fHCLK ≤ 168 MHz
      - Scale 1 for 168 MHz < fHCLK ≤ 216 MHz. The over-drive is only ON at 216 MHz.
      Just FYI my clock is at 216MHz and I have not touched these registers so it seems like scale 1 is the reset value. Please let me know if there is anything else I can do to help or if you know where I can find more descriptive information to answer your question.

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

      Did you saw the first video of this series ?

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

      @@ControllersTech Oh whoops yes I did but I set the register to the reset value (0b11) which is scale 3

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

    great job thank you !!!

  • @slawekh7862
    @slawekh7862 4 ปีที่แล้ว +2

    How ST came up the idea to calcutate baudrate. It is so stupid. But there is much simply way to calculate baud rate. Take frequency for UART preiferial divide by preferd baud rate and put trzys walue to the baud register. this walue is the same as this awful method of calculating baud rate according to Reference Manual

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

      Could they have made it any more complicated. I doubt it.

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

    Thank you very much

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

    Great work

  • @Crazy-vk5sl
    @Crazy-vk5sl 4 ปีที่แล้ว +1

    Thanks -^-

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

    👌👌👌👌👌👌👍👍👍👍👍👍👍👍👏👏👏👏