CAN deserves some explanation indeed. As for SPI, I always regarded it as one of the simplest protocols out there, more than UART, since there's almost no device link data structuring (like UART with start, parity or stop bits). The data structure is probably only dictated by the type of device you want to communicate with.
These videos are the gift that keeps giving. I used this very video over a year ago to help me get up to speed and it was invaluable today as well. Thanks Shawn!! printf and its derivatives are capable of printing floating point numbers by the way, no need to juggle the number and print the integer and fractional parts separately.
Excellent explanation! Even as a mechanical engineer with no previous formal knowledge on this, I am able to understand! Now I understand how "easy" arduino makes all this, for beginners
@@ramimehyar481 at 12:20, you can see that there are two different functions for either writing to, or reading data from the I2C device. They will set the 8th bit accordingly.
@@ramimehyar481 Indeed. But just to be sure, I also looked it up again. You find it on the Wikipedia page as well as in the I2C standard, which is very well written (it's linked from the Wiki page).
I'd really like to see your simple, concise explanation for reading and writing to an SD card with SPI. That would also solve other stuff I want to do with SPI.
Many thanks Shawn! I'm really motivated to finish this course, but already in this second lesson I'm running into the complexity of STM32 programming. It's not like the standard C to me, especially with those crazy HAL functions. Also, your programs are quite elegant and professional, which means in plain language that they are not friendly for C beginners, or at least not for me. But I don't give up and keep going.
hello ! i felt the same trying some code in RTOS for ESP8266 but guess what , nowadays everything is like this , and most of sw is copy paste.... so our good old days are over.... let´s get used to very high level of abstraction to use these tools unfortunately....
Why didn't we change last bit(R/W bit) of the TMP102 address from 0 to 1 in HAL_I2C_Master_Receive function in order to read data from the slave, as you mentioned in 09:20? I think we could easily do that by TMP102_ADDR | 0x01.
@@zxm-19 0x01 is the adress of temperature register where in the hal i2c master transmit function it will take care of R/W bit if u using transmit function means R/W bit set to 0 and if u using Recive then it set to R/W bit set to 1
I would like to complement this amazing tutorial by pointing out a few issues: 1) the 2s complement comment should state that you are actually extending the 2s complement encoding from 12 bits to 16 bits; 2) the float value is converted to unsigned int in the printf, so negative values will not be displayed correctly.
I still confused with that part of the code. I was expecting that the a value that is in 2s compliment would require several steps. The steps I would expect would be: checking if most significant bit is a 1. Then if true, invert all bits and add a one at lsb location. But here he just does logic OR with 0xF000. I am confused...kindly explain.
@@JasperHatilima 12:56 the temp sensor has only 12 bits, but val is a 16 bit signed integer (int16_t). Then, he checks if the most significant bit of the 12 bit temperature sensor reading is active by testing (val > 0x7FF). When he does the or-ing (val |= 0xF000) he is just extending the 16 bit variable with leading ones so that the whole 16 bit variable accurately represents a 2-complement value
At 11:48, he does something to show the parameters for HAL_Status... I'm assuming that it's something from a right click menu, but I can't figure out what it is...
Did you get an answer for this obvious question? I asked it again, i want to know the same! I guess the hal_ transmit and receive parameter does that, but i want to know how
Thanks. I ran into a curious issues. After following this on a Nucleo-64 I added an OLED 128x64 1306 to the I2C bus. The debugger/programmer couldn't reach the MCU. The MCU was running, but hthe STLNK couldn't reset it. I reviewed the wiring and found by simply connecting the OLED to the 3,3V pin was enough to cause the programmer to fail. It makes no sense. I check the OLED on an ESP32 and it worked perfectly. It's almost as if the 3.3V regulator is overloaded with the chip+tmp102+oled.
Great tutorial, used this in part to setup an ADS1115 connected to a LM60 on the BluePill. Just one thing though: sprintf((char*)buf, "%u.%02u C ", ((unsigned int)temp_c / 100), ((unsigned int)temp_c % 100)); } This will fix chopping of leading zeros for the decimal value. (ex: 20.09 = 20.09 and not 20.9)
With NUCLEO-F303RE I keep getting only ErrorTX, i'm sure my pins are in the right position and the code is correct, anyone know what the issue could be?
Nice explanation. A per my understanding we are reading two bytes [buf[0] and buf[1] from the temperature sensor. could any one please explain for the combining bytes buf[0] 4. Why left shit and right shift by 4?. Thanks
so some of my USB ports don't put out enough current for this board. its a bit more hungry than some boards iv played with in the past. the board would disconnect at stlink updates
Superb videos (I only watched the first two) but product environment is extremely complex. The vendor needs to simplify the dev environment for new users or their only customers will be experienced engineers: that will not allow the vendor to increase sales. So... consider a tiered learning level from simple to moderate to complex. As a course developer/instructor for 23 years before retirement, I have found this to be a successful approach.
Hello Shawn, it´s the best tutorial I have ever seen. Thank You. I only have trouble with displaying the symbols on puTTY. In the device manager my board STM32L100 is not listed as Com Port, but as an USB-Device. Do I need a special driver?
How does the mastertransmit and masterreceive toggle the last bit 1 or 0 to determine if we are writing or reading? I do not see how Hal_ could know this from the datasheet of the sensor! Otherwise, how then are we sending this last bit accordingly?
Thanks a bunch for the great explanation, i wonder if you have an example of SCD30 CO2 sensor or if y can guide me because i didn't get good results so please answer me asap! thanks
Dave you add 1 to your binary number then flip all the numbers to 1 if they were 0 and 0 if they were 1. i.g. Your binary number is 1001011 so after adding 1 you’ll get 1001100 and finally you’ll have 0110011
val is an int16_t, so what we're doing is looking to see if the first bit of our 12-bit number is 1. If it is, we pad 0xF to the front of the 12-bit number (making it a 16-bit number that starts with b1111). Because it's a signed int16_t, the 2's complement will be automatically performed for us, resulting in the correct negative number. Hope that helps!
Aaahhh. You C programmers are spoilt. ;) I'm an assembly guy and we (generally) have to do it the long handed method: ori #$F000, reg1 not reg1 addi #1, reg1
I am using stm21f722ZET6U Nucleo board, I tried to program for simple LED Toggle and I selected the nucleo board and configured RCC and SYS and Selected in built LED in as output but when i try to generate the code for it its not generating the code
I did same things on anoteher card of stm32 from stm32F103 series but I got something wrong messages like ''huart2' undeclared (first use in this function)'. How can get rid of this problem? Do you have any idea?
your explanations are good but I've tried for HTS221 sensor and i'm getting always tx error even i changed the slave address. Can you please do a video on MEMS sensor (IKS01A2).
Hardware Abstraction Level - a layer of programming that allows a computer operating system to interact with a hardware device at a general or abstract level rather than at a detailed hardware level
Could you make a tutorial for updating the virtual COM ports for Putty -> STM serial connections? Windows 10 has made the COM ports obsolete and its been impossible to debug. Tried 6 tutorials to fix the issue for COM ports and nothing works.
now after finishing this code it would have been interesting to add another device, maybe an SPI device and show how to do that without losing my own code.
Hi, firstly thank you very much for the useful video. But I still got a question. In my case, the result looks something like error tx or rx between the actual temperature. Here is the picture imgur.com/djMx7oE
@@WhyAndWhatIf-Questions the problem for me was, the pins, u know how there are 2 rows of pins for the nucleo right?, i addidentally put the wire on the first row instead of the second row. Its my first time making this mistake. How i figured out my mistake is by making use of the other i2c pins, there are 4 total pins for i2c1, u can use either one of the pairs, for me the first one didnt work because of the pin mistake, so i decideded to use the second pair, then it worked and i found my mistake, hope this helps, u can try making use of i2c2 as well if u have
The tutorial isn't made for the temperature sensor, but for the STM products utilizing HAL. There really isn't much complexity using HAL as demonstrated in this tutorial anyway.
The best explanation I've found so far, one video about SPI and CAN communication would be amazing!
CAN deserves some explanation indeed. As for SPI, I always regarded it as one of the simplest protocols out there, more than UART, since there's almost no device link data structuring (like UART with start, parity or stop bits). The data structure is probably only dictated by the type of device you want to communicate with.
These videos are the gift that keeps giving. I used this very video over a year ago to help me get up to speed and it was invaluable today as well. Thanks Shawn!!
printf and its derivatives are capable of printing floating point numbers by the way, no need to juggle the number and print the integer and fractional parts separately.
Excellent explanation! Even as a mechanical engineer with no previous formal knowledge on this, I am able to understand! Now I understand how "easy" arduino makes all this, for beginners
Are u an unit vector? Because you give my life direction
these videos are brilliant, so clear , to the point and highlights all the important stuff including error handling... and I love the bow tie!
Bro, these tutorials as a refresher from my final year course has been a life saver! I can't thank you enough!
What did you study? :D
@@Everflamen Electrical Engineering
I just bought 3 STM32 Disco boards from Digikey. These videos are great. Thanks Digikey!
Very very nice explaination dear! You're the Reason I understand the programming of stm for the first time.
Man your explanations are perfect. It's just the right rythme I need, thank you !
Incredibly sharp and concise tutorial!
Can you please explain to me how we sent the 8th bit to determine if we are writing or reading?
@@ramimehyar481 at 12:20, you can see that there are two different functions for either writing to, or reading data from the I2C device. They will set the 8th bit accordingly.
@@Hirnlappen thank you, i have assumed the same, so that means that this w/r bit is a standard i2c protocol to be at that location?
@@ramimehyar481 Indeed. But just to be sure, I also looked it up again. You find it on the Wikipedia page as well as in the I2C standard, which is very well written (it's linked from the Wiki page).
Your explanation to every topic is very good and easy to understand.
Thank you
Ohh man while are telling, assume that you are uploading my brain such a Matrix. Thanks 🙏
Awesome vid, can you make one for SPI as well?
I'd really like to see your simple, concise explanation for reading and writing to an SD card with SPI. That would also solve other stuff I want to do with SPI.
I don't like it, it jumped from hello world to operating bytes
Amazing explanation about I2C. Please make one for SPI
Many thanks Shawn!
I'm really motivated to finish this course, but already in this second lesson I'm running into the complexity of STM32 programming. It's not like the standard C to me, especially with those crazy HAL functions. Also, your programs are quite elegant and professional, which means in plain language that they are not friendly for C beginners, or at least not for me. But I don't give up and keep going.
hello ! i felt the same trying some code in RTOS for ESP8266 but guess what , nowadays everything is like this , and most of sw is copy paste.... so our good old days are over.... let´s get used to very high level of abstraction to use these tools unfortunately....
Thank you very much, this video helped me before breaking my neck. Saved my time.
Why didn't we change last bit(R/W bit) of the TMP102 address from 0 to 1 in HAL_I2C_Master_Receive function in order to read data from the slave, as you mentioned in 09:20? I think we could easily do that by TMP102_ADDR | 0x01.
I have the same question
@@zxm-19 0x01 is the adress of temperature register where in the hal i2c master transmit function it will take care of R/W bit if u using transmit function means R/W bit set to 0 and if u using Recive then it set to R/W bit set to 1
@@zxm-19 and 0x01 is not R/W bit it is Temperature register adress
I would like to complement this amazing tutorial by pointing out a few issues:
1) the 2s complement comment should state that you are actually extending the 2s complement encoding from 12 bits to 16 bits;
2) the float value is converted to unsigned int in the printf, so negative values will not be displayed correctly.
I still confused with that part of the code. I was expecting that the a value that is in 2s compliment would require several steps. The steps I would expect would be: checking if most significant bit is a 1. Then if true, invert all bits and add a one at lsb location. But here he just does logic OR with 0xF000. I am confused...kindly explain.
@@JasperHatilima 12:56 the temp sensor has only 12 bits, but val is a 16 bit signed integer (int16_t). Then, he checks if the most significant bit of the 12 bit temperature sensor reading is active by testing (val > 0x7FF). When he does the or-ing (val |= 0xF000) he is just extending the 16 bit variable with leading ones so that the whole 16 bit variable accurately represents a 2-complement value
Best teacher ever---Thanks
Great tutorial. Please make more.
Which tool need to use simulate STM nucleo board and code.
Ethernet tutorial for sure will be awesome!
At 11:48, he does something to show the parameters for HAL_Status... I'm assuming that it's something from a right click menu, but I can't figure out what it is...
It's F2... nevermind!
Why the address for reading/writing stay the same ? We should do something like this "TMP102_ADDR | 0x01" in order to add 1 ?
Did you get an answer for this obvious question? I asked it again, i want to know the same! I guess the hal_ transmit and receive parameter does that, but i want to know how
Always a pleasure to watch these tutorials :) Keep them coming.....
I am getting "Error Tx". The UART worked with "Hello!".
Hello, me too.
Hey for me it works now. I got obly a smd chip of a temperature sensor. I pulled the data pins with 10kohms to vcc and now it works.
One of the best explanations, thank you
Is there a reason why it's preferable to declare TMP102_ADDR and REG_TEMP as private variables instead of macros at around 10:40? Thanks!
so he can declare it as uint8_t and shift it
It's just the 2nd video and I already want to buy a Nucleo
the diagram & schemetic is not there anymore for the nucleo-64 boards datasheet :( 2:11
Why my browser insists in showing me subtitle for this video in Korean language???
I guess there is a confusion when performing 2s complement. I dont think this will work for negative temperature. Please correct me if wrong
Super nice videos!!! Only thing that confuses me is your intergalactic talking speed ;)
Thanks. I ran into a curious issues. After following this on a Nucleo-64 I added an OLED 128x64 1306 to the I2C bus. The debugger/programmer couldn't reach the MCU. The MCU was running, but hthe STLNK couldn't reset it.
I reviewed the wiring and found by simply connecting the OLED to the 3,3V pin was enough to cause the programmer to fail. It makes no sense. I check the OLED on an ESP32 and it worked perfectly.
It's almost as if the 3.3V regulator is overloaded with the chip+tmp102+oled.
Do I have to end debug session in order to receive anything from COM port? I'm not able to get any data via USB while in debug session.
Great tutorial, used this in part to setup an ADS1115 connected to a LM60 on the BluePill.
Just one thing though:
sprintf((char*)buf,
"%u.%02u C
",
((unsigned int)temp_c / 100),
((unsigned int)temp_c % 100));
}
This will fix chopping of leading zeros for the decimal value. (ex: 20.09 = 20.09 and not 20.9)
damn the smile at the end of every explanation is so awesome
With NUCLEO-F303RE I keep getting only ErrorTX, i'm sure my pins are in the right position and the code is correct, anyone know what the issue could be?
Me too :(
Nice explanation. A per my understanding we are reading two bytes [buf[0] and buf[1] from the temperature sensor. could any one please explain for the combining bytes buf[0] 4. Why left shit and right shift by 4?. Thanks
Great videos thanks, perfect for STM32 beginners... On another unrelated note, your hair looks like something out of a cartoon :)
How did your code work when you had no pull up resistor? You didn't even set the internal one
so some of my USB ports don't put out enough current for this board. its a bit more hungry than some boards iv played with in the past. the board would disconnect at stlink updates
Superb videos (I only watched the first two) but product environment is extremely complex. The vendor needs to simplify the dev environment for new users or their only customers will be experienced engineers: that will not allow the vendor to increase sales. So... consider a tiered learning level from simple to moderate to complex. As a course developer/instructor for 23 years before retirement, I have found this to be a successful approach.
Please one similar for SPI, great video!!!
As always, great tutorial! Very helpful. Thanks alot!👍
Hello Shawn, it´s the best tutorial I have ever seen. Thank You. I only have trouble with displaying the symbols on puTTY. In the device manager my board STM32L100 is not listed as Com Port, but as an USB-Device. Do I need a special driver?
How does the mastertransmit and masterreceive toggle the last bit 1 or 0 to determine if we are writing or reading? I do not see how Hal_ could know this from the datasheet of the sensor!
Otherwise, how then are we sending this last bit accordingly?
Thank you fornthe video content
I cannot thank you enough!
Thanks a bunch for the great explanation, i wonder if you have an example of SCD30 CO2 sensor or if y can guide me because i didn't get good results so please answer me asap! thanks
Very good explanation! Thanks a lot for it 👏
what could prevent UART from transmitting that we need to make use of HAL_MAX_DELAY?
Very informative and condensed video :)
I don't understand how you did the 2's complement
Dave you add 1 to your binary number then flip all the numbers to 1 if they were 0 and 0 if they were 1. i.g. Your binary number is 1001011 so after adding 1 you’ll get 1001100 and finally you’ll have 0110011
Dave is right. Line 129 sign extends the float value to correctly ensure the number is negative, but the additional code is missing. Temps
val is an int16_t, so what we're doing is looking to see if the first bit of our 12-bit number is 1. If it is, we pad 0xF to the front of the 12-bit number (making it a 16-bit number that starts with b1111). Because it's a signed int16_t, the 2's complement will be automatically performed for us, resulting in the correct negative number. Hope that helps!
Aaahhh. You C programmers are spoilt. ;) I'm an assembly guy and we (generally) have to do it the long handed method:
ori #$F000, reg1
not reg1
addi #1, reg1
@@BobBeatski71 minimizing a long task with some abstraction doesn't mean they are spoilt :)
Learned a lot thanks. Would be very helpful if you could add a similar tutorial video on SPI.
Amazing tutorial! Thank you very much
I am using stm21f722ZET6U Nucleo board, I tried to program for simple LED Toggle and I selected the nucleo board and configured RCC and SYS and Selected in built LED in as output but when i try to generate the code for it its not generating the code
excellent. very useful
Is there any tutorial on I2C low level driver?
I did same things on anoteher card of stm32 from stm32F103 series but I got something wrong messages like ''huart2' undeclared (first use in this function)'. How can get rid of this problem? Do you have any idea?
your explanations are good but I've tried for HTS221 sensor and i'm getting always tx error even i changed the slave address. Can you please do a video on MEMS sensor (IKS01A2).
Great video, well explained. I am a newbie to STM32.... What is HAL?
Hardware Abstraction Layer www.datarespons.com/pros-cons-using-stm32cubemx-code-generation-tool-insead-manually-writing-drivers-arm-cortex-m-microcontroller/
Hardware Abstraction Level - a layer of programming that allows a computer operating system to interact with a hardware device at a general or abstract level rather than at a detailed hardware level
I would say Shaun's coding style is good.
How would this work with a gyroscope? That's what I'm trying to figure out.
Can somebody explain me why it's necessary to cast buf to a char pointer when using strcpy?
This is amaizing.
This guy is a compiler by himself... He doesn't need any IDE
Could you make a tutorial for updating the virtual COM ports for Putty -> STM serial connections? Windows 10 has made the COM ports obsolete and its been impossible to debug. Tried 6 tutorials to fix the issue for COM ports and nothing works.
What about device like AD7147 that can be used to connect to 13 sensors? How to read using STM32? Example?
hi friend, may you make tutorial in INA219 Current sensor please.
where are the hi2c1 and huart2 declared?
I tried to do the same with the MPU6000 but it didn't work. I always Error Tx.
Use *dmesg | grep tty* command in Linux to find the serial port.
how 0x48
now after finishing this code it would have been interesting to add another device, maybe an SPI device and show how to do that without losing my own code.
¿Can run in an ESP32 board ?
excellent!
can you please share the steps performed in this video in written form? i couldn't find it at the site
Hello,
Our Maker site is currently down for maintenance. Please check back in a couple of days. Sorry for the inconvenience.
WOW Super Tutorial !!!
Hey man. Why you left shifted ?.! One time ?.
mine keeps giving me error :/
u r legend
that was a lot to take in
korean subtitles?
you spoken very speed
very good tut. can u share the code?
found it on digikey website, thx
@@yanhuiyuan5686 where did you find the code? can you share the link, i couldn't find it in the site
@@yanhuiyuan5686 hi, can you share the link? i couldnt find it in the site
www.digikey.com/en/maker/projects/getting-started-with-stm32-i2c-example/ba8c2bfef2024654b5dd10012425fa23
Hi, firstly thank you very much for the useful video. But I still got a question. In my case, the result looks something like error tx or rx between the actual temperature. Here is the picture
imgur.com/djMx7oE
you are not alone
@@abutaymiyyahlectures did you find solution?
@@WhyAndWhatIf-Questions actually, yes i did
@@WhyAndWhatIf-Questions the problem for me was, the pins, u know how there are 2 rows of pins for the nucleo right?, i addidentally put the wire on the first row instead of the second row. Its my first time making this mistake. How i figured out my mistake is by making use of the other i2c pins, there are 4 total pins for i2c1, u can use either one of the pairs, for me the first one didnt work because of the pin mistake, so i decideded to use the second pair, then it worked and i found my mistake, hope this helps, u can try making use of i2c2 as well if u have
Too complicated for "getting started part 2"!
You too fast and the quality of the videos is not good. Hope you could do it like Paul McWhorter in his Arduino tutorials it would be better
N'est video ever!
Best
Ridiculous complexity. Just use an Arduino, the libraries do 95% of it for you.
The tutorial isn't made for the temperature sensor, but for the STM products utilizing HAL. There really isn't much complexity using HAL as demonstrated in this tutorial anyway.
Amazing explanation. Thank you very much!
hi friend, may you make tutorial in INA219 Current sensor please.
hi friend, may you make tutorial in INA219 Current sensor please.