STM32 UART Ring Buffer using DMA and IDLE Line

Поделиться
HTML-код
  • Опубликовано: 11 дек 2024

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

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

    important function
    5:33 IsConfirmed ( int32_t Timeout)

  • @BanGoo-sk4gk
    @BanGoo-sk4gk 5 месяцев назад

    이 코드의 문제점은 tx 중에 rx 인터럽트가 걸리면 rx가 busy 상태에서 빠져 나오지 못하는 치명적인 문제점을 발견했습니다. 해결방법은 tx 전에 interrupt를 disable 하는 것인데, 간헐적으로 동일한 문제가 발생하는것을 발견했습니다. 이러한 방식을 사용하시면 안됩니다.

  • @leonardogarberoglio3611
    @leonardogarberoglio3611 3 года назад +1

    Hi, great video!!! some devices (like GPS) sends data in short burst with big delay between them (20msec of data every second) and we need to parse the data as soon as it get available. All this examples will work ok and we doesn't loose data. But if we are not synchronized with the burst we will be parsing data from the previous second. Can you cover this special case?

  • @nodahandong1
    @nodahandong1 3 года назад +1

    Thank u. But can you add function for hex data for rx and tx ring buffer as well. It might help some body who is working on project hex command either string handling. Thank u again and looking to see that.

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

    Hello ControllersTech;
    My question is this project works with ESP32-S3 instead of ESP8266 ?
    Other question why this one set rendom values in those buffers in the main function:
    extern uint8_t MainBuf[128];
    getDataFromBuffer("*", "#", MainBuf, buffer);

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

    If i start the code while there is already communication present on the RX-line, the program refuses to receive anything.
    However if i start the program while the RX-line is in idle mode it always works.
    Any ideas on what is the cause und how to fix it?

  • @tranconginh5284
    @tranconginh5284 3 года назад

    I have a question. My arm chip use 2 uart1 and 2. Get data by uart 1 with high speeed 9600. After it will send data by uart2 with speed 300. Can you help me solution for over buffer. Thanks! My chip str912faw

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

    Hello can you make a new video for managing multiple Uart? In my opinion these codes are better than previous one.

  • @vinhphamquang8209
    @vinhphamquang8209 3 года назад

    Thank sir, but i got some troubles when follow this tutorial:
    1. I run the debug and "stuck" at this line "while ((!isOK)&&(TIMEOUT));" ( and any loop within your function, i tried remove TIMEOUT, only using isOK ) , even though the TIMEOUT hit the negative number, and keep decreasing, or isOK become 1, it always stuck at while loop within isConfirmed of waitFor function. The strange thing is when it was stuck, I can receiver data from incoming uart buffer normally, even isOK variable change arrcodingly. I'm using STM32F103C8T6 with KeilC v5.
    2. I am have some misunderstanding about ringbuffer, at the first time when the RxBuffer received data, and push the data into MainBuffer, you will get a big MainBuffer with exactly the data which the sender sent, then you do something with that data, why didnt you flush the Mainbuffer afterthat, and it will clear and ready for the next data.
    3. Is goto statement good? I heard that it is not recommended in C
    Great video and Thank you so much!

    • @ControllersTech
      @ControllersTech  3 года назад

      1. I don't know whats wrong with that. All i can say is don't halt the cpu while the data is being received or you will losse the data.
      2. The buffers are being used as ring buffers. We already keep track of which data is being read. So flushing will do nothing special. It's just the waste of cpu cycles.
      3. Using goto is not good. But if used properly, it's not a bad move..

    • @vinhphamquang8209
      @vinhphamquang8209 3 года назад

      @@ControllersTech
      1. I add HAL_Delay(1) into "while ((!isOK)&&(TIMEOUT));" and it worked. Dont know why @@
      2. Ah, i read about the ringbuffer and got the idea. Your MainBuf is circular so every your function or method are written with handling this circular too.
      As my very childlike thinking, i thought if the data isn't too big, i will receiver everything and push into a buffer, then do work with it.
      Then, i will flush everything and wait for the data again
      Thank sir!!!

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

      @@vinhphamquang8209 can you please tell how did you resolve the problem of while ((!isOK)&&(TIMEOUT))

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

    Hi
    Is this able to apply with the ESP32 dev board? Anything needs to modify?

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

    @Controllers Tech , I wanted to receive 234KB (KilloBytes) of data through SIM7600 module UART.
    What shiuld be by RxBuffer Size?

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

      Keep higher than 234..

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

      @@ControllersTech But the RAM size is only 128KByte. What should i do?

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

      Oh i thought 234 bytes..
      You can use small buffer like 512 B for Rx and 1KB for main buffer.
      See the data is going to be 234KB but it's not going to come at once. It will cone in chunks.. so i think 512 bytes should be okay

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

      @@ControllersTech Thank you Sir, I will try this

  • @ArjanvanVught
    @ArjanvanVught 3 года назад

    You are using an USART, that different from an UART. Does the same apply for UARTs?

  • @chiuong1199
    @chiuong1199 3 года назад

    Thank you for this video

  • @bohanzheng6820
    @bohanzheng6820 3 года назад

    Great video and it really helps! I am wondering why you have always used Normal DMA mode instead of Circular. In your previous video and this one you sort of already made a ring buffer to handle long data. Why not just use the built-in version of ring DMA?

    • @bohanzheng6820
      @bohanzheng6820 3 года назад

      I guess you probably want that IDLE line interrupt to fire which won't with circular mode enabled? Is that correct guess? Otherwise, you would have to build a parser on it.

    • @BanGoo-sk4gk
      @BanGoo-sk4gk 5 месяцев назад

      같은데이터가 반복적으로 버퍼에 쌓이기때문에 normal로 설정해야 합니다만, 이 코드의 문제점은 tx 중에 rx 인터럽트가 걸리면 rx가 busy 상태에서 빠져 나오지 못하는 치명적인 문제점을 발견했습니다.

  • @tarkucar8040
    @tarkucar8040 3 года назад

    thank you, it's so nice but i got an issue and i couldn't solve this. I use the h743zı2 so i complete all CORTEX M7 RELATED videos but receive data is not correct. for example always sending letters like 'ü ÿ þ' . I cant send a string from hercules but ı can send data from teraterm byte by byte. do you know how ı can solve these problems?

    • @ControllersTech
      @ControllersTech  3 года назад

      Check the baud rate in Hercules. Incorrect characters appears due to different baud rates between source and destination

    • @tarkucar8040
      @tarkucar8040 3 года назад

      I don't think so this didn't work for me. I solved when change the HSE value from 25Hz to 8Hz thanks anyway..

    • @ControllersTech
      @ControllersTech  3 года назад

      It's not something you solved. If your board have 8 MHz crystal and you setup with 25 MHz, how would you expect it to work ?

    • @tarkucar8040
      @tarkucar8040 3 года назад

      Yeah you are right it's not a solvable problem it's my fault sorry

    • @JesusChrist-sx1lf
      @JesusChrist-sx1lf 3 года назад +1

      @@ControllersTech Well you can set it up to work for 25MHz if you go with the PLL clock. That's what most people do nowadays, using a lower crystal and scaling it. However I suppose that's not what he meant.

  • @pedrohenriquearaujoneves7173
    @pedrohenriquearaujoneves7173 3 года назад

    Hello !! I love your videos, could you make a video about how to use LCD with I2C DMA?

    • @ControllersTech
      @ControllersTech  3 года назад

      There already is a video about lcd using i2c.
      If you want to use dma, then instead of simply using I2C transmit, just use I2C transmit DMA

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

      @@ControllersTech I wanted to receive 234KB (KilloBytes) of data through SIM7600 module UART.
      What should be by RxBuffer Size?

  • @bobby9568
    @bobby9568 3 года назад

    great work!

  • @atlesg
    @atlesg 3 года назад

    Thank you sir! :D

  • @fernando.liozzi.41878
    @fernando.liozzi.41878 3 года назад

    Thanks!!!! Excellent!!!!

  • @thangnguyenduc6628
    @thangnguyenduc6628 3 года назад

    perfect video

  • @miguelestrada2011
    @miguelestrada2011 3 года назад

    Excelent!

  • @theraja011
    @theraja011 3 года назад

    Thx

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

    thank you for the video