Transmit data using UART in STM32 || Poll || Interrupt || DMA

Sdílet
Vložit

Komentáře • 70

  • @rcfreakamit
    @rcfreakamit Před 3 lety +2

    Great tutorial! Thanks. I especially liked the interrupt based transmit example. I've been spending many hours trying to get it to get to to work w/no success. this video solved the puzzle :)

  • @Abhishekkumar-vf8qe
    @Abhishekkumar-vf8qe Před 5 lety

    Thanks for providing a great tutorial

  • @k.t.d.chathumisamaraweera9477

    Thank You very much for sharing your knowledge...!!!

  • @ravisoni2228
    @ravisoni2228 Před 4 lety

    awesome video....heartly thanks

  • @dryoutube5150
    @dryoutube5150 Před 6 lety +1

    Awesome work can u provide a video on interfacing 10dof IMU with help of cubemx

  • @psykjavier
    @psykjavier Před 4 lety

    this video have helped me, in my case , i had not enabled in NVIC the USART2 interrupt, hence , the fuction HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart) was not triggered, thank you..!!

    • @psykjavier
      @psykjavier Před 4 lety +1

      you have won a subscriber..!!

  • @cristianorodriguesdasilva6107

    Great! Have you ever worked with RS485? Could you make a video explaining about it?

  • @yalginayyaltirik4607
    @yalginayyaltirik4607 Před 4 lety

    thank u sir!!

  • @vicki211
    @vicki211 Před 3 lety

    Exceptionally clear, and a terrific introduction to the three methods. Would you please share why you made the choices you did for the clock settings rather than use the defaults? Particularly for using the PLLCLK? Thanks again, looking forward to exploring more of your work.

    • @ControllersTech
      @ControllersTech  Před 3 lety

      I always use the max sys clock with input from the external crystal. There is no particular reason for it though.
      Even if you set the external crystal and type in the sys clock frequency and hit enter, cubemx can generate the appropriate setup for you

  • @hro688
    @hro688 Před 2 lety

    Hi! Could you please advise how to find a necessary function in lib? Search for text occurences is completely useless, it doesn't return anything. There is a possibility to searct for a methods available in Idea for example (ctrl + f12)

  • @ajitnayak1541
    @ajitnayak1541 Před rokem

    Good work. Is there sample code with synch uart mode

  • @023-mohammadsyawal7
    @023-mohammadsyawal7 Před rokem

    thankyuu

  • @empireearth2716
    @empireearth2716 Před 2 lety

    Thanks You! One question, if I would like to print a variable, how can I do?

  • @clubunity9342
    @clubunity9342 Před 3 lety

    well actually Dma is different from interrupt cause it can access all peripherals,data,etc,. from the mcu directly without wasting cpu cycles.although,nice video.

  • @umarahmad1497
    @umarahmad1497 Před 5 lety

    Can you please provide video of I2S working with CubeMX, i am running into this problem of HAL_TIMEOUT as my data is read only once ....

  • @ahkamnashiruddin7053
    @ahkamnashiruddin7053 Před 4 lety +1

    this is an amazing tutorial, in my project only send once when using DMA. Could you help me? Thanks.

    • @ControllersTech
      @ControllersTech  Před 4 lety +1

      You xan use hal_uart_dma_stop after transmitting once.

  • @stuff2learn07
    @stuff2learn07 Před 2 lety

    It looks like interrupt runs in parallel? The LED blink is not at all affected. Can you please explain this phenomenon? I was under impression that in interrupt the processor halts its current process and continues what ISR has asked it to do and then resumes where it had left.

    • @ControllersTech
      @ControllersTech  Před 2 lety

      Yes what you wrote is correct. But this entire process is very fast, so the effect on the LED is negligible. It's because the interrupt is getting triggered during the delay period.
      The best practice to handle ISRs is to write them as short as possible.

  • @MehmetAliTurhan
    @MehmetAliTurhan Před 2 lety +1

    Could we use UART2IRQN Handler function instead of the TxCallback function for interrupt mode and what is the difference of these two methods?

    • @MehmetAliTurhan
      @MehmetAliTurhan Před 2 lety +1

      The reason of my question, when I was working on hardware interrupts I have used handler functions, I did not use callbacks, however in here you did not use the Uart interrupt handler function. So where do we use Uart interrupt handler or what is the purpose of this function?

    • @ControllersTech
      @ControllersTech  Před 2 lety +2

      Once the interrupt is triggered, the IRQ handler is called. This Uart irqn is used to handle the interrupt, Where it clears the necessary flags. After handling all the necessary things, it will call the callback. This callback function is typically designed for the user application.
      Ofcourse you can write your code in the interrupt handler itself, but this callback method is common in all sort of peripheral functions. This way we don't really need to worry about handling the interrupt and we can focus on our part of the code.

    • @MehmetAliTurhan
      @MehmetAliTurhan Před 2 lety

      @@ControllersTech Thanks for your explanation

  • @tytuer
    @tytuer Před 5 lety

    That's a great video, but I want to transmit data coming to tx pin rather than transmitting predefined buffer. How is that possible? Thx for your help.

    • @ControllersTech
      @ControllersTech  Před 4 lety

      You have to first receive the data and store it in a buffer. After that you can transmit the buffer. Check my latest video. That might exactly be what you are looking for

  • @yassin5568
    @yassin5568 Před 3 lety

    Great Video Bro😊
    Can you tell me please how can I delete the received data from Rx_buffer (UART interrupt) in order to receive new data from Rx_buffer[0] ?

    • @ControllersTech
      @ControllersTech  Před 3 lety

      Clear the buffer
      Write a new function which can write null ('/0') to the buffer

  • @embedded_eng
    @embedded_eng Před 9 měsíci

    10:12 on the screen tx rx pins are left empty. How did you get the serial transmission characters? Virtual com port or any other?

    • @ControllersTech
      @ControllersTech  Před 9 měsíci

      Yes through the virtual com port. In nucleo boards uart2 is connected to the virtual com port.

  • @naveensiva170
    @naveensiva170 Před rokem

    Thanks for the video. If we use two UART in Interrupt mode, then HAL_UART_TxCpltCallback will be called at the end of the tx interrupt. But how do we identify or differentiate on which UARTS TX is complete?

    • @ControllersTech
      @ControllersTech  Před rokem

      You can identify the instance that called it.
      Inside the txcmpltcallback function use the if loop to identify the instance.
      If (huart->instance == uart1) { do something}
      It could be UART1 or USART1 depending on your mcu.

    • @naveensiva170
      @naveensiva170 Před rokem

      @@ControllersTech Thanks for the clarification

  • @hro688
    @hro688 Před 2 lety

    When I wirte uint8_t [] data or uint8_t data[] or uint8_t * data it doesn't compile (expected identifier or '(' before '+' token). Any idea why, guys?

  • @mahilyaeswaran1019
    @mahilyaeswaran1019 Před rokem

    can you please mention that vision firmware package name?

  • @armincal9834
    @armincal9834 Před 3 lety

    thanks for the tutorial! do you know where i can find the full list of all the HAL functions? or at least all HAL functions related to a particular protocol like UART,I2C etc.
    i mean how do you guys know that these functions exist?

    • @ravimali2814
      @ravimali2814 Před 3 lety

      You will find them in project_name/Drivers/STM32F4xx_HAL_Driver/Src/ c files of all enabled functions

  • @electronicswithmadhan1052
    @electronicswithmadhan1052 Před 5 měsíci

    Whether you created this project in stm32 cubeide and imported it to keil ?

    • @ControllersTech
      @ControllersTech  Před 5 měsíci

      Better watch the latest video on this channel..
      After watching it, watch this one part 2
      czcams.com/video/JaMwNT0m3Sw/video.html

  • @illidan2514
    @illidan2514 Před 3 lety

    sry i kinda bad at english hope u understand . So im used uart1 connect to lora uart e32 and im used HAL_UART_Transmit to send a simple data like "hello", and im used another lora uart e32 connect to my computer to see the data on hercules (both lora are same channel setting) but i didnt see any data show up . can u help me pls

    • @ControllersTech
      @ControllersTech  Před 3 lety

      I don't know about lora. Check the datasheet.. you might need to set the connection type, baud rate and all.
      Also make sure the pins are always connected as tx to rx and rx to tx.

  • @prapulkrishna
    @prapulkrishna Před 2 lety

    Hi,
    Apparently that’s a huge improvement using call back completion interrupt. But still transferring 2000 bytes of data is big and how does that ensure interrupt call back is speeding the data transfer. I mean even without interrupt it’s still the same amount of data. So during interrupt, active task is blocked and interrupt takes over CPU which means the same effort spent by CPU. So what exactly is the speeding factor here??? Can someone please explain? I would greatly appreciate. Thanks

    • @ControllersTech
      @ControllersTech  Před 2 lety +1

      It's not speeding... If you don't use interrupt, the cpu will be blocked until 2000 bytes are received. You can't perform any other operation.
      With interrupt, other task can carry on while the data is being received in the background. Once the 2000 bytes are received, the interrupt will trigger, and the cpu will process the data.

    • @prapulkrishna
      @prapulkrishna Před 2 lety

      @@ControllersTech Thanks for the response. With that understanding, Interrupt Call Back facilitates the elimination of need to use CPU for data transfer as it's fulfilled by ISR. Am I correct?

  • @ProjectAssistant-yc9qg

    hello sir. i am doing same using cube mx ide for STM32L4S5 but nothing print on hercules can any guide.Please

  • @kavorka8855
    @kavorka8855 Před rokem

    I can confirm that the DMA version in this video doesn't work on stm32f7 series, it works OK on stm32f4, though.

    • @ControllersTech
      @ControllersTech  Před rokem +1

      DMA is a bit more complicated in cortex M7 series.
      Check out cortex M7 playlist, the MPU video series. Then try it.. it will work.

    • @kavorka8855
      @kavorka8855 Před rokem

      @@ControllersTech You're awesome!

  • @franckciccio8032
    @franckciccio8032 Před 2 lety

    Hi, Can I receive with interrupt and trasmit with another interrupt? It doesn't work to me :(

    • @ControllersTech
      @ControllersTech  Před 2 lety

      What you mean transmit with another interrupt ?

    • @franckciccio8032
      @franckciccio8032 Před 2 lety

      @@ControllersTech I mean an echo program: I receive the data and trasmit what I received

    • @ControllersTech
      @ControllersTech  Před 2 lety

      Why transmit with another interrupt ?
      Just send the data inside the callback of the received interrupt

  • @rushikeshchaudhari5264

    how can i print this data on notepad

  • @rushikeshchaudhari5264

    i want to send R letter from stm to PC to print on notepad

    • @ControllersTech
      @ControllersTech  Před 2 lety

      Uart can only send the data to serial monitor. You can write an application for PC which can print that data on the notepad.
      Other option would be to emulate the STM as a keyboard, then you can print where you want

  • @shubhamkumaragarwal7347
    @shubhamkumaragarwal7347 Před 11 měsíci

    When I run the polling method code, the led blinks correctly but I am not able to view the TX data in console view, What could be the possible reason?

    • @ControllersTech
      @ControllersTech  Před 11 měsíci

      Put the array in “live expression”, not in “expression”

    • @shubhamkumaragarwal7347
      @shubhamkumaragarwal7347 Před 11 měsíci

      How do I view the data I am transmitting using HAL_UART_Transmit, It does not show any data in "command shell console" in the console

    • @ControllersTech
      @ControllersTech  Před 11 měsíci

      What board are u using ?

    • @shubhamkumaragarwal7347
      @shubhamkumaragarwal7347 Před 11 měsíci

      STM32F407G Discovery board

    • @ControllersTech
      @ControllersTech  Před 11 měsíci

      Are you using any usb to ttl converter ? The connection should be in cross.. Tx to Rx and Rx to Tx