Multi-Channel ADC with STM32 using DMA and Interrupt- Multiple Analog Sensors

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

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

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

    at 7:12 you cast rawValues as a uint32_t pointer, however rawValues is a 16 bit array with a size of 2. This means that 32 bits in total are taken up by rawValues.
    You give your uint32_t casted rawValues a size of 2, which would tell the compiler that you have 64 bits allocated for this buffer. Wouldn't this be a vulnerability as it is *possible* to overwrite an unrelated address?
    Am I missing something here?

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

    At 3:53 Why did you tick the ADC1,ADC2,ADC3 interrupts? Is it because you are using multiple channels? If I am using a single channel then should I tick it or not?

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

    Excellent work, very clear, structured and informative presentation on a popular topic for STM32. Congratulations Sir.

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

      Thanks you! I'm glad you enjoyed this STM32 tutorial. Best wishes!

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

    thank you.
    anyway i am wondering, in line 126 (minute 10:20): why does the code has to iterate it until i < number of conv. ?
    i can understand if it is only 2 number conversions so that the code only does the iteration once since it is 2-1.
    say, for example, if we have 3 number of conversions, then the code there will have to iterate twice since it is 3 - 1. So reading adc chanel 0, 1, 2 twice?

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

      Not only are you right about that, but there is a final line missing: reset the "convCompleted" variable to zero.

  • @unknown.477
    @unknown.477 ปีที่แล้ว +2

    this multiple ADC doesn't work for me. I'm using nucleo G070rb . What may the reason..?

  • @CAN_MIKE
    @CAN_MIKE 10 หลายเดือนก่อน +2

    Hello, I don't understand why you have to reset the board to obtain a new value from the ADC, in theory the DMA ADC would have to do it

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

      Hi Mike. you're right to make this multiple ADC with STM32 short I did conversion in while loop. Otherwise to avoid press RESET button I'll have to add few more lines on code. To keep video short I prefer this way of reading multichannel ADC in video lesson.

    • @abelashenafi6291
      @abelashenafi6291 10 หลายเดือนก่อน +2

      @@BINARYUPDATES Hey man, can you please add the few lines of code to avoid resetting the MCU all the time and see the values change in real-time? This would be really really appreciated. Regardless, you just earned a subscriber. Kudos

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

      @@abelashenafi6291 To avoid the reset it is only necessary to reset the "convCompleted" variable to zero

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

      @@abelashenafi6291 HAL_ADC_Start_DMA add this code inside the while loop. Also its good to use HAL_ADC_Stop_DMA inside the conversion complete callback function

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

    Very nice, I dont need to make the video faster because you speak on a very reasonable speed.

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

    I don't think you need a for loop at 11:30 to get values for `lux` and `pot`, also resetting mcu doesn't help much

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

    Thanks for the superb explanation. I learned quite a lot! But why do we need to reset the MCU every time we need to read the input voltage of each Analog pin? is there anyway where we could read the input voltage without resetting the MCU?

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

    Why were the channel cycles set to 480 cycles instead of 3?

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

      The 480 cycle is an optimal and most common choice to make sure we achieve resolution and accuracy while reading ADC value. If we choose 3 cycle then it will be very fast and it'll not allows us to read analog pins to maintain stable output from ADC channel of STM32

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

      @@BINARYUPDATES Perfect, thanks. Yeah, I'd assume at some point it will not finish reading the ADC channels before the next cycle begins. So in cases where sample rate isn't critical it makes sense to select the slowest sample rate (480 cycles).

  • @muralikrishna.3252
    @muralikrishna.3252 5 หลายเดือนก่อน

    very intro about dma in stm32....i have implemented in stm32f446re. but i am unable to visualize adc data which is changing in live expression tab.it is freezing at initial value. how to change it? any solution would be appreciable.

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

    Thanks a lot :)

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

    Brother Im using NUCLEO-L452RE so what I do if i want to make all 16 channels in active mode

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

    How did you learn all this? I would also like to know this way. Would you be able to recommend any books or courses?

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

    Excellent explained

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

      Thank you
      Good luck and best wishes!

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

    why we need to reset the board any reason behind it?

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

      Hi Dileep, this code only read value once from ADC channel. But it keep printing on UART continuously. If you want to see the changed ADC values on serial terminal then you've to modify the program. While making video I needed ADC conversion only once at interrupt so i used same code but you can easily modify. Best wishes!

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

    Nice Video Sir!!!

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

      Thank you so much Santamanyu. Best wishes!

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

    how come you're not resetting the flag after the blocking while loop?

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

      Because he's only doing one reading from the ADC. If you check his code, he never does another conversion. He is manually resetting the board to force another conversion. No need to reset the flag if it is only used once.

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

    sir please make the video on SPI and I2C

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

      Hi Khichadeneeta, I'll try to find time soon to finish making videos on using I2C and SPI peripheral to interface different sensors with STM32 Microcontroller. Thanks for your patience. Best wishes!

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

    I should use a DMA with a lot more samples (32, 64 ones) to work them after in order to use DMA advantages

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

    Nice video, can u share the code and instructions?

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

    Please give me a link to the previous video on the stm32

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

      Hi Whiteknighte, the video of Single channel ADC is in description section. Also, check entire playlist of STM32 Nucleo Board. Thanks!

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

    Kindly tell that why we are pressing reset button to see new value, why don't we get new value automatically. I understood everything it was informative video but this Question kindly answer. Anyone can tell me i need the answer i am learning this.

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

      HAL_ADC_Start_DMA, the code responsible for taking reading is not inside the while loop. so it only takes the reading once. So maybe adding it inside the loop helps.

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

    I'm using STM32 NUCLEO-F411RE chip... Can you help me write a code to make it capture an image using OV2640 and store it in pc folder?

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

    I haven't seen a schematic, but from the "wiring explanation" I got the impression that you are feeding the ADC input from 5V and not from 3V3. You have to be careful with that, because not every input of the micro controller is 5V tolerant.... And if you use one that is not, it may get damaged due to the 5V...
    So, actually I just checked on the stm32 forum : 5V tolerance does not apply to analog inputs at all, and you should not go beyond min(VDDA, VREF+) +0.3. VDDA and VREF+ are on the nucleo boards I have, Nucleo-743ZI2, equal to VDD_MCU which is dependent on a jumper setting and is either 3V3 or 1V8.... so be careful with that, and check the board schematic to see what VDDA and VREF+ actually are on your board, most likely 3V3 with the standard jumper setting like on the one I have.

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

    Good job. But slowwww down.

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

      Thank you! I'll incorporate your suggestions. Best wishes!

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

    This is awful.

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

    I have problem with line
    while(!convCompleted);
    this 'while' clause does not guard... [-Wmisleading-indentation] main.c
    This code working only one time.
    What can i do?

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

      The code is written to print ADC value only once using Single conversion. So when we press RESET button then only next ADC conversion happen. It's because of the use of interrupt in code. if you make ADC conversion code in while loop then it will print continuously in continuous conversion mode instead of single conversion mode. I hope this may help you. Good luck and best wishes!

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

      Actually, while(!convCompleted); means : "loop until convCompleted becomes true", and there are no additional statements needed, and the semi-colon at the end means an "empty single statement". You can have a single statement after a control structure, such as a while or an if, without the need of curly braces {....} which is called a compound statement, if there is only one or an empty statement following it. So while(cond) stat; a control structure with a single statement, is equivalent to while(cond) {stat;} and while(cond); a control structure with an empty statement is equivalent to while(cond){}. This short form without the curly braces is more convenient to write, but can be ambiguous and a source of very subtle mistakes and that is why the compiler checks for this. For example while(cond) ; {.....} means : a while loop with an empty statement, (like in this code) followed by an "unguarded" compound statement. But maybe there is a typo in the code and what was actually meant was while(cond) {.... }. This can happen because while typing you are used to put a semi-colon at almost every line and so a mistake like this is easily made and very hard to track down. And that is why the compiler warns about this, because it can not know what was actually meant. But the construct here is correct, but writing it like while(!convCompleted){} is more readable and will silence the compiler ⚠️.
      P.S, because the compiler warns about "misleading identation" maybe if you write it like this,
      while(!convCompleted)
      ;
      So putting the semi-colon on the next line, and indent it, will silence the compiler as well. But you need to try that, most of the time "white space" is ignored so maybe this does not work, but using empty curly braces, so while(cond){} should always work.