Thanks a lot for your hardwork!, best material about ADC on YT based on registers not HAL's! You have good way to pass information which is unique :)
@TuanAnhNguyen-mn6yx6 ай бұрын
I check in the Ref Manual, the input pin should be set as analog input, but anyway, thanks for the detailed video on the ST32 series, im still watching it in 2024. One of the best series on this, not HAL
@jacobdavis0005 жыл бұрын
Thank you SO MUCH!! Because of your video, I finally got the ADC working on an STM32F103. ADC is the only thing left that I needed Arduino runtime for. Now I'm free of the Arduino library!!! Also I needed someone to put a map function out there so I didn't have to write my own. Thanks!! ;v))
@jacobdavis0005 жыл бұрын
... but I still need an SPI driver so will probably write my own if I don't use HAL.
@EdwinFairchild5 жыл бұрын
@@jacobdavis000 yeah I was planning on doing spi this weekend but I am really sick right now with the flu so maybe next weekend . Arduino map function is showed on their website thats the one I use.
@siddiqhabib96273 жыл бұрын
very nicely explained .. thanks for correcting about the pin configuration as analog in description.
@amrmusa7217 Жыл бұрын
HOW DO I NO THE CORRESPONDING PINS TO THE A CERTAIN CHANNEL
@EdwinFairchild Жыл бұрын
It’s in the data sheet www.edwinfairchild.com/2020/03/stm32-documents-every-programmer-needs.html
@MilanKarakas6 жыл бұрын
At12:10 on your video, you mention alternative register set: 5
@EdwinFairchild6 жыл бұрын
I will try to answer your questions later tonight. I am in California right now doing an internship and I have no car so I am,walking all over the place
@EdwinFairchild6 жыл бұрын
ok so the answer to this questions is yes, which im sure you tried it by now saw that it works... When you set a register like this: GPIO->CRL |= 5
@MilanKarakas6 жыл бұрын
@@EdwinFairchild Thanks.
@mpkdon11 ай бұрын
Sir,how that delay function is working? How it is exactly gives millisecond delay? Or am i missing some standard keyword for milli second?
@samtavassolian14923 жыл бұрын
Thank you, Eddie. where can I find your sample code?
@gopalagrawal22703 жыл бұрын
Sir can you make a video on ADC triggered through external event like timers for stm32.
@buildlover99594 жыл бұрын
Hi Eddie and thanks for great videos. If like you said adc starts conversion by setting ADON for the second time, what's the purpose for SWSTART bit on CR2 register? Seems they both do the same task and trigger the ADC.
@EdwinFairchild4 жыл бұрын
Yes but for SWSTART to work you have to select it as an external event trigger in the EXTSEL register Bits 17-19 page 241 of RM0008 and you still have to use ADON to turn on the channel
@buildlover99594 жыл бұрын
@@EdwinFairchild Thanks. My intention is to trig the ADC for start conversion at TIM1 update interrupt while it's configured as PWM generation and center aligned. So I am able to do voltage measurement at the middle of PWM ON time.
@surya.62834 жыл бұрын
i am getting random values whether i connect voltage to the pin or not. and the values are about 5 digits.
@ntal58592 жыл бұрын
Just need to correct you on the push pull part.. you are using an analog signal therefore you set it to "no Pull" then the reading is not corrupted then on weak signals. A pot is a very strong signal, but on something like k-type probe it would destroy it. (yes I have used k-type on ADC )
@PavelLaminar5 жыл бұрын
Hi, Eddie the first of all biggest thanks for not using HAL and SPL ))) Please say what a color scheme you use?
@EdwinFairchild5 жыл бұрын
i just manually set the colors in the preferences....
@MilanKarakas6 жыл бұрын
Eddie, please help... I am stuck again... No matter what, can't get result from pin B1 using: if ((GPIOB->IDR & 0) ==1) { printMsg("B0= %d ",1); } else printMsg("B0= %d ",0); and setting: RCC->APB2ENR |= RCC_APB2ENR_IOPBEN; GPIOB->CRL &=~(GPIO_CRL_CNF0_0|GPIO_CRL_MODE0_1|GPIO_CRL_MODE0_0); GPIOB->CRL |= GPIO_CRL_CNF0_1 ; What I am doing wrong? Thank you in advance. Maybe you should make video about input registers GPIO, pull-up/down and similar.
@MilanKarakas6 жыл бұрын
Oh, got it! It should be: if ((GPIOB->IDR & 1) ==1) , it is confusing between register "IDR0" and first bit of this register, which is not 0 but 1 - for that reason why and operand does not works (1 & 0 = 0, not 1 as I wanted).
@EdwinFairchild6 жыл бұрын
I was about to tell you because I just saw the comment but I see you figured it out. Always ask yourself if you are talking about bit position or bit value
@MilanKarakas6 жыл бұрын
Hey Eddie, I have some specific problem; I want to read data from the pin (modified Miller), but stuck on one problem - when trying to shift (1
@EdwinFairchild6 жыл бұрын
Try just setting bsrr to the value of the bit instead of shifting. Example setting bit 3. : BSRR = 8 As oppose to BSRR = 1
@MilanKarakas6 жыл бұрын
@@EdwinFairchild Oh, I messed up my question. What I am doing is making strobe pulse every 9.44 uS, and then additional four pulses as a marker to compare on logic analyzer. Each pulse represent 1/4 of symbol time, and after each pulse there is sampling to see whether there is signal low or signal high. If signal low at first 1/4 or no low signal at all during 4/4 of the symbol period, then bit is read as zero (0). If signal is low at 3/4, then and only then bit is read as one (1). The problem I have is with sampling of all four sub-symbol periods (if low occur outside 1/4 or 3/4 field, then it is error). I am unable to figure out how to read symbols that fast and fill 8 bit register at proper time. All what I got so far is read only one byte (that was in Arduino environment), but if there are two or more bytes, then situation become more complicated due to additional parity bits (single byte = start bit+7 bit data+end, two or more bytes = start bit+8bit data +parity bit, and at the end some end or stop bit). Not to mention CRC/16-A, but that will come later. So, what is my problem is setting bit(s) inside single byte per data that arrive on some pin. Then after 8 bits check parity bit, then continue reading data. I am not talking about setting output pin. Just pushing bit inside byte, depending of reading from another pin (data input)... so, something like: if first bit is 1, then (1
@EdwinFairchild6 жыл бұрын
@@MilanKarakas I okay if understand correctly the main problem is: sampling an input pin and AT SAME TIME that you are trying to shift bits into a byte the bit shifting causes some sample error... cant you just read all samples and then do what you need to do ... i am also thinking you could add an interrupt that will trigger on state change of the pin and record a timestamp and you could use the time information to decode.... aside from this im not sure how to help, maybe look into how others have decoded the same thing maybe with other platforms and then t might help you to figure out for stm32 platform.
@MilanKarakas6 жыл бұрын
@@EdwinFairchild Yes, time - or better said if out of sync, nothing is good. I will try read samples first, then process it later. Interrupt... yes, it will be fine if I know how to do it, but I don't. Others... I did not find anyone do it with MCUs, everything is done in Linux and Python. Thank you for your help, I hope I will figure out.
@MilanKarakas6 жыл бұрын
@@EdwinFairchild Yesterday I tried to run timer 4, but failed at many levels. Only your routine works for PWM. It will be fine if I can sample pin status at some point of the counter (at compare part, end, whatever). So far, I manage to sync at least beginning of the timer with while loop that wait for first pulse. The rest is headache.
@mazinfo39785 жыл бұрын
thank you very much for this tutorial , why you have to check the end of conversion flag if(ADC1->SR & ADC_SR_EOC) while you use end of conversion interrupt ?
@EdwinFairchild5 жыл бұрын
I have to go back and read but I believe there is a single interrupt line, so it could be that something else triggers the interrupt, and also sometimes reading the flag is required, but i have to go look at that again, I know I wouldn't do it for no reason, I just don't remember right now.
@yasirfaizahmed20034 жыл бұрын
I do have one doubt, where is ADC1_2IRQ_Handler() function called? is it gets called automatically?
@EdwinFairchild4 жыл бұрын
It's a handler, no one calls it, hardware is hardwire to go to specific address when an interrupt happens . That address is the handle address. So no one calls it hence no return value or arguments ever exist in an isr
@surajdev20625 жыл бұрын
Thank you sir.. Your video is very helpful for all who want to learn st microcontroller. Once again thank u 🙏💕
@ilkeraykut70645 жыл бұрын
Thanks for the video but I got a question.This is normally working without interrupt but I put interrupt it does not work.What could problem be?
@EdwinFairchild5 жыл бұрын
Somewhere some setting you forgot or missed. I have no way of knowing what your problem could be I cannot see your code in my mind lol.
@ilkeraykut70645 жыл бұрын
@@EdwinFairchild I am using with Lcd.I can get the values on the LCD with nonsense charecters.How can I send the code to you?
@AS-zs7jw3 жыл бұрын
Hi Eddie Amaya! i m facing a problem with this code, that is , when i write the code with enabling the EOCIE (end of conversion interrupt enable ), then this code stuck at that point, and when i use polling while(!(ADC1->SR & ADC_SR_EOC )); val=ADC1->DR; then this code wroks properly, can you please help to solve the problem? than you
@EdwinFairchild3 жыл бұрын
are you clearing the interrupt
@AS-zs7jw3 жыл бұрын
@@EdwinFairchild no, just going to interrupt handler and get data register value, i did not notice any interrupt clearning part in video, i thought that interrupt will be auto cleared by interrupt handler function.
@AS-zs7jw3 жыл бұрын
@@EdwinFairchild data sheet says " EOC: End of conversion This bit is set by hardware at the end of a group channel conversion (regular or injected). It is cleared by software or by reading the ADC_DR. 0: Conversion is not complete 1: Conversion complete " this bit is cleared by reading ADC_DR, which i m doing in interrupt handler function, but still it does not work
@EdwinFairchild3 жыл бұрын
What's the rest of your code look like.
@AS-zs7jw3 жыл бұрын
@@EdwinFairchild how i can send you my code? email id?
@sujitha81532 жыл бұрын
how to download your code?
@EdwinFairchild2 жыл бұрын
No download just type. lol sorry i did not save this anywhere
@nakseungchoi71542 жыл бұрын
You are amazing. I should read the reference manual thoroughly. I missed the part where ADON has to be enabled twice 0; Thank you!
@EdwinFairchild2 жыл бұрын
yeah probably a design flaw, thats usually the story behind weird init sequences
@mpkdon11 ай бұрын
Yea me too lol!
@sagarkanade83834 жыл бұрын
Your programming style is nice.. Can you make a video on USB??