Programming microcontrollers in the C language. Documenting what I have learned over the years in the hope that it will be useful to someone trying to learn firmware development.
Currently have a series of tutorial videos on Microchips PIC18f4520 PIC microcontrollers. Currently in the prosses of creating a series of videos on the ATmega328P AVR microcontrollers at the register level.
List of Microcontrollers I have worked extensively on. -PIC18f4520 -dsPIC30f2020 -ATmega328P (Register level) -nRF52832 (SDK12.3 - SDK16) -nRF52840 (SDK15 - SDK16) -Arduino (Whatever you can throw at me. If it has documentation) -ESP8266 (Arduino and RTOS SDK) -ESP32 (Arduino and IDF) -STM32 (STM32CubeIDE)
Wrong question. How do I know what the value should be or what does the macro do are better question. Answers: It is the default chip clock. Macro is used set timing for some of the builtin functions. Explained in detail here: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-E-UMOx7qv2k.html If you truly want an answers to your question, copied it from prep code.
ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-Lg_00KVXiwQ.html ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-yvcAiSN7u8I.html you'll have a better time looking for SWD (serial wire debug) than for ISP.
Hello Binder. I have been following ur channel for some years now and like ur comprehensive tutorials. Are there any other channels you post some material? Linkedin?
Nothing really. Most likely I will only duplicate what is already got on here if I decide to use another platform. Thanks sticking around for 3 years. I used to be somewhat active on twitter and patreon a few years back but it was mostly it was directing back to here. Links are in the description it you want to have a look.
Thank you for sharing. What are you using to program the STM32 BluePill? I have tried ST-Link V2, ST-Link-V3 and USB ST-Link clones but nothing works. Depending upon the programmer I get error reports telling me the device (STM32) is not responding. This is a common complaint with the later issues of STM32CubeIDE. Can you please help?
Get an original st-link-V3 mini ~$10. I used a Segger J-link EDU, it is no longer manufactured. ST does not like people using closes with their software. If you setup a you own tool set the clones work fine. If you want to use ST tools you are going to have to use a Segger or an ordinal ST-Link. If you got a Nucleo you can hijack the ST-link from it.
Why the ADc reading procedure is this much complex? why Cube Mx Ide not providing some simple way to read ADC channels one by one in programs .when I work with ADCs the inter channel interference is a big issue.Nobody is addressing the real problems any where. According to me the methods used By Microchip Risk Processors are very simple. The explanations about the Control register bits are confusing. Waste Of time to work with cube IDE. select channel,switch it to sample and hold,start sampling ,give result. i really dont understand why ppl are talking bla bla bla much on a simple ADC process...
You seem very distressed. You do not understand because you have never done serious high speed DSP. No-one uses the basic ADC on a STM but you still need to under stand it. The meat and potato's sit with DMA. Zero clock cycles wasted on operating the ADC. Set it and forget it. It will sample in the background. You only need to read the sample data out fast enough. Hands down the best ADCs I have ever used are from ST. Renasa is a close second. "select channel,switch it to sample and hold,start sampling ,give result" Exactly the same for a ST chips when using blocking samples. "Microchip Risk Processors" PIC is horrendous. "inter channel interference is a big issue. Nobody is addressing" This is a you problem. Fix your circuit. You likely have capacitive coupling caused by something external.
Jy het nog nooit silent errors dan al gesien nie. As ek dit kan sien het hy dit gegooi. Toys uit die kot uit op die vloer. "Error vomit" is n ander term wat ek like.
Cause you are using a SAM device. Last time I checked the support for Atmel chips was terrible on MPLAB. Try Microchip-studio (Atmel Studio) ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-BHryCFw2U30.html
Hello! I'm trying your code out, and it didn't work for me. It seems like there may be a problem with the configeration settings. So, can I ask, are the configeration settings the same as what you showed in the first couple of vidoes in this series? If they are the same, do we need to make sure we set it, generate the source code (with all the #pragma lines) and then copy and paste that to the beginning of the code from github?
This is the source code github.com/Devilbinder/PIC18F_Analog_Temperature Have you been able to light up the segment display? Just display a single number nothing else. Have you been able to read the temp and nothing else? No config change, it be in the video otherwise.
ru-vid.com/group/PLtuqBdbsL-DvbB6QAGgoGBAEsGuXfGFoF In short you will need a programmer/debugger/ICD. You can also use this code with a Arduino uno and upload via the bootloader. I only cover programming with a Pickit 4.
Hi. I have a question. in the video I hear you say 22 uF capacitors to be used across 16 MHz crystal oscillator but I see in the guidebook it says 22 pF. I am little confused here. Can you please clarify? Thanks again
Sou experiente no assunto sim, me refiro no problema que esta acontecendo no oxilador pwm stm32f103c8t6, só liga se eu tocar chave ou pinça no gnd do mesmo.tenho muitos inversores com esse problema que usa essa micro.
Sounds like a floating ground. Can't help you without taking measurements myself. Google translate is not helping much for the language barrier also. Parece um terreno flutuante. Não posso ajudá-lo sem fazer as medições sozinho. O Google Tradutor também não está ajudando muito com a barreira do idioma.
Prerequisites Flash ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-Y3jCXTGmWww.html Bootloader ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-vqnTSHW7beo.html USB serial ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-WZHooXeoXAs.html
Maybe you can help me. How do you turn OFF FastPWM AFTER initializing/starting the signal? I was thinking about TIMSK1 &= ~(1 << OCIE1A); but it doesn't work
You want stop the clock of the timer to stop PWM. TCCR1B &= (0b000<< CS10);. You might need to write the pin manually to a known state. Your other option is to set the duty cycle to 0% or 100%. TIMSK1 only enables or disables the interrupts.
...to further elaborate: because you have 2 Buttons that both could potentially trigger a rising/falling Edge, so now where does it say in the code that it was the Button on Pin X and not Pin Y that triggered that Edge?
K so you got two questions 1 ".. where there is going to be a rising/falling Edge" 3:30 The register is set to tell it witch edge you use. 2 "...so now where does it say in the code that it was the Button on Pin X and not Pin Y that triggered that Edge" 4:25 Testing witch flag was set
@@BinderTronics I found the Problem. So, I am using the PIC24FJ512GU410 and now I had somehow overseen this, but you have to use a Pin that has a INT compatibility (obviously; and that also answers the questions; because now the pic knows what Pin it has to be checking for a falling/rising Edge). But since my PIC has so many Functions the Datasheet (or where the data sheet shows what Functions what pins have) didn't show INT1/INT2 etc. so I thought I could use any PIN hence my confusion. Now when I was reading though many datasheets it turned out that I have to map INT1/INT2 etc. Functions to specific Pins because my PIC has so many Functions it didn't fit them all on every Pin. So now I have to use PPS (Peripheral Pin Select) to assign INT1 for example to Pin X and then I can turn on the rising/falling Edge and then it will hopefully work! Thanks you none the less, I love your videos
All we care about is, is the LED bright enough? If yes then the resistor value does not matter as long as it is within or under the current spec. Can the MCU IO drive/sink the LED at max current? Most cases not. Do we care about the efficacy? No, I would be running the LED on PWM then. Do we have a datasheet for the LED? No, best to over spec for the current then. Secondly your calculation is wrong. The current is the same through each component in a series circuit. 5V/0.02A = 250R E6 330R-470R E12 270R-470R
@@BinderTronics no calculation is good for me, you have 1.6V drop consumation by the led (Led voltage drop : 1.6V, current limitation : 0.02A) thank you for your advices, your lessons are very good
Please start a series on nrf52. Also, which sdk is suitable because I heard that nordic is moved to nrf connect sdk so starting with soft device is suitable or not?
This is the official getting started guide: developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/installation.html They have move all their support into the Zephyr SDK. I was not a fan the last time I used it.
12Mhz is fine. you will need to re-compute any values that involve timings yourself. 22pF is a rule of thumb value. 12-22pF should work for most crystals. MCU datasheet section 9 for clocks. For loading CAPs refer to the datasheet of the crystal.
Hello again Binder. I am following your videos and trying to replicate to learn. I have been stuck a few days without being able to power on my Led0 (13GPIO). I did everything exactly but nothing. After doing other tests, I found that putting MX_GPIO_Init(); in the main.cpp would make it work. Toggle is working fine. Do you have any clue about what I could be doing wrong? I would like to learn from this and I have exhausted my resources before asking. At least now is working!! Let me know when you can share me any tip. Thanks
GPIOBase constructor is not running, Try running the debugger and step the code. ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-vlJ_80EbMS8.html around the 8 min mark I use the debugger.
@@BinderTronics hey there! I managed to fix it. I was missing a line GPIObase::init(); in gpio_hal.cpp. I could focus on that file since the init was there so I double checked again. Now my questions are, What was the purpose of doing these files and settings with public and private. its to being able to init the Douts, keep them away from the main file and being able to call them with a short name? I am trying to understand the logic behind. Thanks!
For files. It simply comes down to organizing code and reuse. Imagen having a book without chapters or a index. This is what will happen if you use a single files. Real projects can easily be 10k-3M lines depending on complexity. So we break the project down into files that govern a particular purpose. gpio_hal.h only governs the outputs and inputs. The name used or length has no relevants. Just name it something logical. For class access modifiers: public: anything can access it. private: only that class can access it. protected: only that class and its derived classes can access it. It is object orientated programming (OOP) theory. Covered in most courses for languages that have OOP components.
I really appreciate your work. I would like to study further C++. There are a lot of books right there, Could you recommend me one that you think that would be a good investment of time to learn from? (aside from this content that is really helpful). Thanks again!
I would recommend C over C++ as a first language. I did not learn from books. What I recommend in general for whatever language is to lookup a course on RU-vid to get the fundamentals. Once you got fundamentals start your own project to solve a problem you have or something you find interesting. The is the only way you will truly learn is by doing, not by parroting tutorials. freeCodecamp.org has a metric ton of courses. w3schools is good if you want a text base course. The Cherno is pretty good for C++ as a supplement (I like the code review stuff). Fair warning, C++ can become awful real fast. GPT chat is also a fantastic learning tool to figure out how something works. It produces awful code most of the time and can't debug but it is still great if you know nothing about a topic.
@@BinderTronics Oh that's great. Even though I'm no expert in C. I played something with PiC16 using C for embeddeds but I found out that as things get complex is a little hard to deal with, also the capabilities of the pic itself. But thank you for the tips. Even saying that helps by doing it's useful. Today I discovered that one class that I'm taking will focus in C++ for the rest of the semester and I have to code a big project. this will help me with this too . we are using Arduino Uno there. so I will play with both. Thanks mate
C++ is for the most part "backwards" compatible with C. C structures are not 100% compatible with C++ structures. C++ treats a struct the same as a class with the default access modifier as public instead of private. You will see me use a mix of C and C++ in the later videos. C++ is not C and vise versa.
Got it some time back from a local retailer. If you want a J-link you will probably have to get a J-LINK EDU MINI or get a Nordic DK with a J-link OB. For ST you can get a ST-Link V3 mini and a adapter board. If you are brave you can use a FT2232 with OpenOCD. Most of these items are sold on digikey, mouser or RS. My J-Link EDU seems to be marked as obsolete. So you are going to have a hard time finding the same one as mine.