No video

STM32F4 Discovery board - Keil 5 IDE with CubeMX: Tutorial 3 ADC single conv - Updated Oct 2017

  Рет қаралды 56,615

Mutex Embedded

Mutex Embedded

Күн бұрын

This tutorial shows how to implement ADC single conversion mode using three different programming levels:
1. CubeMX + HAL libraries [0 to 6 mins].
2. HAL libraries only [6 to 19 mins].
3. Register level programming [19 to 25 mins].

Пікірлер: 77
@cahitkiyicioglu3450
@cahitkiyicioglu3450 2 жыл бұрын
thank you bro 🇹🇷
@mursalaboobacker3593
@mursalaboobacker3593 2 жыл бұрын
Can you help sir
@mursalaboobacker3593
@mursalaboobacker3593 2 жыл бұрын
no Classic framework option in my keil
@mursalaboobacker3593
@mursalaboobacker3593 2 жыл бұрын
My keil software always shows one option for stmcube framework ie cube mx
@mursalaboobacker3593
@mursalaboobacker3593 2 жыл бұрын
Iam studying all your video coding without cubemx doesn't work
@IF9
@IF9 3 жыл бұрын
شكككرا
@bbbel4254
@bbbel4254 3 жыл бұрын
Is this tutorial can be used for stm32 f429 ,too ?
@grantkobe9
@grantkobe9 3 жыл бұрын
Sir, I have a question. how can you use PA0 as adc1, in the demo board, pa0 is connect to push buttons. Why you can use pa0 and connect to potentiometer?
@DARKVEEMON1
@DARKVEEMON1 3 жыл бұрын
Hi, don't know if you can still respond, but I have a problem. If create a project using CubeMX and then pass to Uvision it compiles and works fine. If I create the project directly in uVision it compiles, but when I try to load it it says: "Error flash download failed - could not load file...". I havwe the same board (STM32F407 VGT6) and do the same code as the video
@saveplanet3977
@saveplanet3977 3 жыл бұрын
really good tutorial for people interested to learn register level programming for STM32F4XX. Thankyou
@dattharshi
@dattharshi 3 жыл бұрын
Thanks for ADC Basic Tutorial!! Please make a video on Analog Watchdog ADC.
@szubskin9555
@szubskin9555 4 жыл бұрын
You add HAL_NVIC_EnableIRQ(SysTick_IRQn) in 16:17, but in your other videos there is just HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0), which is no HAL_NVIC_EnableIRQ. When should the function NVIC_EnableIRQ be used?
@callm3pc
@callm3pc 4 жыл бұрын
Hats off for the amazing job you have done making these videos. from 16:38 to 16:52 you defined the function SysTick_Handler(), but there was no function prototype of function or a call for this function in the main function. Why is that so?
@mutexembedded2206
@mutexembedded2206 4 жыл бұрын
Hey, thanks. For SysTick_Handler(), it is define in the startup file, as part of the Vector Table. Vector Table defines callback for interrupts, so this is one of this for the SysTick Interrupt.
@torpedo35
@torpedo35 4 жыл бұрын
Very good guide. After trying a couple this one was the first that actually worked for me and didn't block .
@apoorvsingh7134
@apoorvsingh7134 4 жыл бұрын
I wanted to read the sensor value from 0-5V but stm32 works at 3.3V. Can you suggest how can I do that?
@mutexembedded2206
@mutexembedded2206 4 жыл бұрын
Voltage divider will work if impedence is balanced
@skylercornell7996
@skylercornell7996 4 жыл бұрын
Hey great videos! I'm confused about the return type of HAL_ADC_Start() and HAL_ADC_Stop(). I see from the HAL src files that they both return a type HAL_StatusTypeDef but you're using both of those functions without assigning their return values to anything. You're just calling HAL_ADC_Start(&hadc1); I guess since in this case we don't really need those return values its okay but I always assumed you needed to assign the values to a variable of a non-void return type functions! Thanks!
@enriquehernandez8197
@enriquehernandez8197 4 жыл бұрын
A great help, thanks so much :D
@batuhangunaydn975
@batuhangunaydn975 5 жыл бұрын
When the code is generated from CubeMX, __HAL_RCC_ADC_CLK_ENABLE() is not used in MX_ADC1_Init() or anywhere else in the code. How is the APB2 clock being activated in that case?
@sharathn9672
@sharathn9672 5 жыл бұрын
Hi, In Register level programming I have executed and tested code without " tickstart = HAL_GetTick(); ", I just used ---> while((ADC1->SR & 0x2) != 0x2) { // if((HAL_GetTick() - tickstart) >10) // { // break; // } } this code by commenting all related "HAL_GetTick()" Function. I got the same output without those. Need Clarification on same.
@Marco-wz3hv
@Marco-wz3hv 4 жыл бұрын
If I do this then my code hangs in the while loop all the time. I replaced the polling section with --> counter = 10 * SystemCoreClock / 1000; //Poll for 10 ms while ((ADC1->SR & 0x2) != 0x2){ //Check EOC flag if (counter
@sharathn9672
@sharathn9672 5 жыл бұрын
Hi, Your Videos are great!!!! I have a question, you have used "Void Systick_Handler(void)" function, but it's not used in this program anywhere, I have executed this program without using systick handler function and it works fine. Can you tell me why it's used?. I mean what is its significance?.
@furkanozcan6124
@furkanozcan6124 4 жыл бұрын
kanka onu biz de anlamadık anladıysan bize de anlatabilir misin gurban olduum
@hieuminhn3410
@hieuminhn3410 5 жыл бұрын
Thanks so much, great tutorial
@thanhthonguyen6171
@thanhthonguyen6171 5 жыл бұрын
hi bro. when you select MCU, you choose STM32F407VGTx, but in " Manage Run Time Environment" tab. you choose "Board support" is STM32F429I-Disco. Can you explain to me why ?. Thanks so so much.
@zibinyuan8254
@zibinyuan8254 5 жыл бұрын
Can u do a tutorial on how to program the accelerometer in STM32F4
@mutexembedded2206
@mutexembedded2206 5 жыл бұрын
Already have one
@qubolo
@qubolo 5 жыл бұрын
Amazing tutorial! I like how you got into details without CubeMX. I learned a lot from that.
@jollymishra8558
@jollymishra8558 5 жыл бұрын
Please can u help me with the maximum and minimum volts of the sin wave that can be given to ADC pin which is in turn given to DAC to produce the signal back.
@josola621
@josola621 5 жыл бұрын
Hi, I am new to STM32 and I am having issues running STM32L476RG Nucleo board without using STM32CubeMX. can you suggest a workaround, please?
@user-zq9xt7ef9l
@user-zq9xt7ef9l 5 жыл бұрын
Thanks!! This is the best stm32 tutorial I have ever watched. Every one should try this.
@EduardoAvilaH
@EduardoAvilaH 5 жыл бұрын
Hello, This are amazing videos. Is there a possibility you can add a video connecting the STM32F407 with the raspberry Pi in Win IoT?
@mutexembedded2206
@mutexembedded2206 5 жыл бұрын
Hi, Not in the time-being I am afraid :)
@Crazy-vk5sl
@Crazy-vk5sl 5 жыл бұрын
Excellent!
@CmZam17
@CmZam17 5 жыл бұрын
nice and clear, Thanks! I am now writing a program for power monitoring IC using stm32 and I have to use these HALL libraries as I am not familiar with HAL libraries, I was wondering if you could do more videos about HALL libraries. Thanks!
@TheKansi2
@TheKansi2 5 жыл бұрын
Hi Sir, My adc value goes beyond 255. With around %70 percent rotation it shows 255 and doesn't changes until %90 and goes 189. ?? Can you help me please. thank you
@mutexembedded2206
@mutexembedded2206 5 жыл бұрын
Hi, ADC input voltage must be between 0 - 3v Yours is apparently 5v
@TheKansi2
@TheKansi2 5 жыл бұрын
@@mutexembedded2206 ah yes... thank you again
@GOPIRAVICHANDHIRAN
@GOPIRAVICHANDHIRAN 5 жыл бұрын
Excellent tutorial.... Is it possible to make one tutorial on PID control.? Like heater control with feedback from temperature sensor..
@arhamtemi2865
@arhamtemi2865 5 жыл бұрын
Hi there, I am current looking for some help / or your tutorial on measurement of ac current using STM32F407 via cubemx (for configuring Current Sensor (Hall Effect) using ADC). It would be much appreciated if you made a separate video of it regardless of pointing me to the ADC tutorial of you.
@mutexembedded2206
@mutexembedded2206 5 жыл бұрын
Hi Arham, Sorry for the late reply,, I am currently having some very time,, won't be able to make a separate video, but will be happy to give some help. Good luck
@proactive_studio
@proactive_studio 5 жыл бұрын
is there anyway of getting a real time watch expression in Eclipse? The tutorial worked but I have to suspend the debugger and then resume again to display a value change on the ADC, not real time at all.
@mutexembedded2206
@mutexembedded2206 5 жыл бұрын
Hi mate, Can use a UART terminal, if you want real-time monitoring.
@mutexembedded2206
@mutexembedded2206 5 жыл бұрын
Use STM Studio
@VarunKaushik18
@VarunKaushik18 5 жыл бұрын
By far the best tutorial for STM32F discovery board I've come across.
@FernandoAFNambi
@FernandoAFNambi 5 жыл бұрын
Extremely helpful! thank you.
@youssefelmzaiti3201
@youssefelmzaiti3201 6 жыл бұрын
Salam Mohamad, I try to trigger ADC with interrupt, but it's not work, so when i debug, i realize the clock config make the problem, i change the clock config in cubeMx, first i'm use the HSE->PLL to put HCLK = 168MHz, and i change to HSI->16MHz , and the interrupt works, so i think there's a relation between CLOCK config and interrupt of ADC ? What are you think ?
@luisuribe3775
@luisuribe3775 6 жыл бұрын
Hey, great tutorials. Sorry, I have a question while in debugging mode I get the next error: "Cannot access target shutting down debug session " Do you know what is causing this problem? I've tried with the examples in Cube and everything goes well but when i try with the registers I get the error. I'm using the same discovery board Thank you!
@mutexembedded2206
@mutexembedded2206 6 жыл бұрын
Hi Luis, I am not entirely sure what causes this error, but if you had your ST-Link debugging settings correct + trace functionality enabled with similar clock speed, you should have no problems. GL
@ferdinvivian9336
@ferdinvivian9336 6 жыл бұрын
Hello Sir, This is the code I used #include "stm32f4xx_hal.h" void GPIO_config(void); void ADC_config(void); void Systick_Config(void); //Default for all program for HAL_Delay ADC_HandleTypeDef hadc1; uint8_t ADC_Value; int main(void) { HAL_Init(); GPIO_config(); ADC_config(); Systick_Config(); while(1) { HAL_ADC_Start(&hadc1); if(HAL_ADC_PollForConversion(&hadc1,5)==HAL_OK) { ADC_Value=HAL_ADC_GetValue(&hadc1) ; } HAL_ADC_Stop(&hadc1); HAL_Delay (100); //100ms delay } } void GPIO_config(void) { __HAL_RCC_GPIOA_CLK_ENABLE(); GPIO_InitTypeDef My_ADC_pin; My_ADC_pin.Pin = GPIO_PIN_0; My_ADC_pin.Mode = GPIO_MODE_ANALOG; My_ADC_pin.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA,&My_ADC_pin); } void ADC_config(void) { __HAL_RCC_ADC1_CLK_ENABLE(); ADC_ChannelConfTypeDef ADC1_Channel ; hadc1.Instance = ADC1; hadc1.Init.Resolution = ADC_RESOLUTION_8B; hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV; hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT; HAL_ADC_Init(&hadc1); ADC1_Channel.Channel = ADC_CHANNEL_0; ADC1_Channel.Rank= 1; ADC1_Channel.SamplingTime= ADC_SAMPLETIME_15CYCLES; HAL_ADC_ConfigChannel(&hadc1, &ADC1_Channel); } void Systick_Config(void) //To use HAL_delay function { // HAL_Delay uses systick interrupt timer, We have to enable it and set //Set clock speed and source HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000); HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK); // systick interrupt priority and enable HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); HAL_NVIC_EnableIRQ(SysTick_IRQn); } void Systick_Handler(void) { HAL_IncTick(); // increment tick } I need to use break point to stop the code and update the ADC_Value in Debugger Mode of KEIL.. If I'm not using break point, My ADC value is not updating.. May I know the reason sir.. I have followed all the steps as you taught
@mutexembedded2206
@mutexembedded2206 6 жыл бұрын
Ferdin Vivian Can't see why it wouln't. Should work just like the above
@ferdinvivian9336
@ferdinvivian9336 6 жыл бұрын
okay sir. Thanks for the reply
@musicalbite7271
@musicalbite7271 6 жыл бұрын
Sir Why i can't get digital output on leds pin no pd12-15 ?
@musicalbite7271
@musicalbite7271 6 жыл бұрын
Is there I need to write the code for gpio output?
@mutexembedded2206
@mutexembedded2206 6 жыл бұрын
surinder bansal Hi, Perhaps you forgot to enable them on CubeMX.
@musicalbite7271
@musicalbite7271 6 жыл бұрын
I mentioned in cubemx gpio output PD12-PD15
@mutexembedded2206
@mutexembedded2206 6 жыл бұрын
surinder bansal Hi, Which STM board are u using? Would definitely work the same with a normal stm board
@musicalbite7271
@musicalbite7271 6 жыл бұрын
Yes sir I'm using stm32f407vgt discovery board
@farouk0161
@farouk0161 6 жыл бұрын
Thank you..very helpful and clear
@gmmaia11
@gmmaia11 6 жыл бұрын
Hey man, great videos! I am learning the basics to program my STM32F4 Discovery board, and I am studying all your videos. There are two things that I am having some trouble to understand: - If the resolution of the ADC is 8 bits, why do you use an int variable with 32 bits to store the value? Could it be int8, to optimize the code? - Why do you use the "start" and "stop" functions inside the while loop? Could it be only one time before the while? Or do you have to start and stop every time that you get a value? Again, great videos! Thanks!
@mutexembedded2206
@mutexembedded2206 6 жыл бұрын
Guilherme Maia Hi Guliherme, Glad to hear that, thanks. 1. That's correct, using uint8_t instead is more efficient. 2. Yes, cuz this is Single mode, and with this you have to start the ADC in order to acquire a new sample,, ADC get value function just reads what is in the ODR register (Output Data Register).
@JoseRomero-wp4ij
@JoseRomero-wp4ij 6 жыл бұрын
@MYaqoobEmbedded What kind of potentiometer do you use? characteristics? By the way, a kindly advice, you shouldn't speed up the voice the tutorial, I realized you modified the speed but it just make it harder to understand, and you also can get a better quality microphone.
@mutexembedded2206
@mutexembedded2206 6 жыл бұрын
Jose Romero Hi Jose, I use a normal 10k potentiometer.
@elyesmehri3067
@elyesmehri3067 6 жыл бұрын
The most beautifu tuto ever, thank you a lot !
@severinmundl2710
@severinmundl2710 6 жыл бұрын
Thanks alot!!!! Great tutorial!!!!
@designworks7347
@designworks7347 6 жыл бұрын
can you make GUI with stm32f429
@mutexembedded2206
@mutexembedded2206 6 жыл бұрын
I think so, yeah. I don't have this board with me atm, you would need STemWin + free compiler (e.g. SW4STM32).
@chahaji
@chahaji 6 жыл бұрын
Exceptional tutorial... Thanks
@rishabhkumar12
@rishabhkumar12 6 жыл бұрын
nice tutorial i learned a lot from ur video can u help in reading multiple channel in stm32f401 without using dma
@mutexembedded2206
@mutexembedded2206 6 жыл бұрын
rishabh kumar Hi Kumar, I dont know much about the stm32f401 but it appears not to have a DMA. An alternative option is to use ADC Interrupt after each single convertion and assign each read value to the specific Analog input. The second option and the simplest is to use ADC signle convertion as in Tutorial 3 but change the channel each time to read different analog inputs.
@rishabhkumar12
@rishabhkumar12 6 жыл бұрын
f401 has dma anyway thanks for ur help keep posting such videos ☺
@asimabdulqayyum3360
@asimabdulqayyum3360 6 жыл бұрын
Great work..Can you do a session on RTOS,,that would be great,,
@mutexembedded2206
@mutexembedded2206 6 жыл бұрын
Hi Asim, I will make a tutorial about RTOS at some point. Thanks
@prabudhabv5532
@prabudhabv5532 3 жыл бұрын
@@mutexembedded2206 still waiting!
managed to catch #tiktok
00:16
Анастасия Тарасова
Рет қаралды 22 МЛН
👨‍🔧📐
00:43
Kan Andrey
Рет қаралды 10 МЛН
The Giant sleep in the town 👹🛏️🏡
00:24
Construction Site
Рет қаралды 17 МЛН
Box jumping challenge, who stepped on the trap? #FunnyFamily #PartyGames
00:31
Family Games Media
Рет қаралды 30 МЛН
STM32 Nucleo - Keil 5 IDE with CubeMX: Tutorial 7 - I2C interface
10:26
managed to catch #tiktok
00:16
Анастасия Тарасова
Рет қаралды 22 МЛН