PIC MCU TUTORIALS #12 - Delays & Built-in delay functions (Absolute Beginner)

  Рет қаралды 6,853

Microesque

Microesque

Күн бұрын

Пікірлер
@luannewatson9195
@luannewatson9195 Жыл бұрын
Very easy to understand,...Thank You
@liviuambrus7411
@liviuambrus7411 2 жыл бұрын
The best explanation for dealy function. Thank you.
@brucelamb6060
@brucelamb6060 Жыл бұрын
Thank you for the absolute noob spoon-feed! Really insightful! Got mine to run off a picket 4 on a pic10f200. Haven't been able to run blinking LED off of independent source, it only runs while connected to the picket. Have prepared a separate bread board to run off a 5v supply as suggested in your previous video.
@Microesque
@Microesque Жыл бұрын
Thanks 👍 The microcontroller should run just fine after disconnecting the programmer. If it isn't, make sure you're actually uploading your code and not debugging. If you upload a debug build, the microcontroller won't run without the programmer. Also, make sure the MCLR pin is either disabled or connected to Vdd with a pull-up resistor so it doesn't stay in reset when the programmer is disconnected.
@tedbastwock3810
@tedbastwock3810 8 ай бұрын
Fantastic explanation, super clear
@sivapriyarnath4377
@sivapriyarnath4377 8 ай бұрын
What is the built-in function for pic24fj128ga704
@Microesque
@Microesque 8 ай бұрын
PIC24 are 16-bit microcontrollers, so the process is a little different. This is why I try to tech how to read datasheets and manuals. Answers to questions like these will almost always be somewhere in the user's guide of the compiler. I've included a short and a long answer below. I recommend reading both, but it's up to you 👍 ------------------------------- *Short answer:* -> Define the "FCY" macro as the instruction frequency of your microcontroller, so for 10MHz: _"__#define__ FCY 10000000UL"_ -> Include the "libpic30.h" library in your code: _"__#include__ "_ -> Now you should be able to use the same "__delay_ms()" and "__delay_us()" functions. Be careful, you need to define "FCY" before including the library! ------------------------------- *Long answer:* -> If you open the XC16 user's guide ( ww1.microchip.com/downloads/en/DeviceDoc/50002071K.pdf ) and go to page 63, there is a section for "How Can I Implement a Delay in My Code?". There, it tells you that there are library functions, but you have to download it to use them. It also directs you to another manual dedicated to 16-bit libraries for XC16. -> If you open the 16-bit libraries document ( ww1.microchip.com/downloads/en/DeviceDoc/16-Bit-Language-Tools-Libraries-DS50001456K.pdf ) and read the introduction etc, it tells you that the XC16 comes with the libraries pre-installed already. You just have to explicitly include them in your code. -> Now you can just search the term "delay" in the page to see your options. After finding the function you're looking for, it tells you which library you have to include, the signature of the function, and also a general description. I recommend you glance over some of the functions, as there are a lot of convenient ones that may catch your eye 👍
@GodsOnlyMonster
@GodsOnlyMonster 2 жыл бұрын
Keep making videos bro
@subhashkendole3005
@subhashkendole3005 Жыл бұрын
How about delay of 120 seconds
@Microesque
@Microesque Жыл бұрын
A single delay function in the XC8 compiler can only delay the microcontroller for at most 50,463,240 instructions. For longer delays, you need to use multiple delay functions. If the delay you want is very large, use a for loop, like 10:02 in the video with a large delay. I must have forgotten to add this limitation when making the video. For a better explanation, read below: ------------------------------------------- The XC8 Compiler User's Guide states that the "_delay()" function can't delay for more than 50,463,240 instructions (page 348). This likely exists as a result of the way this delay function is implemented in the compiler. Don't forget that the "__delay_ms()" and "__delay_us()" functions calculate the instructions needed to achieve a given delay, then call the "_delay()" function with it (you can see it in 3:24). So, if you're running the microcontroller at 64MHz, the highest delay you can generate using the "__delay_ms()" function is 3153ms. -> Calculation: (50463240*1000)/16000000 = 3153 - 50463240 is the maximum instructions. - 1000 is the conversion from seconds to milliseconds. - 16000000 is the instruction frequency. (This also means that the maximum delay you can generate is affected by your instruction frequency.)
@hameheroj4030
@hameheroj4030 Жыл бұрын
You saved me a lot of time. Thank you!
Who is More Stupid? #tiktok #sigmagirl #funny
0:27
CRAZY GREAPA
Рет қаралды 10 МЛН
진짜✅ 아님 가짜❌???
0:21
승비니 Seungbini
Рет қаралды 10 МЛН
Their Boat Engine Fell Off
0:13
Newsflare
Рет қаралды 15 МЛН
How to get source code onto a PIC microcontroller
11:21
FriendlyWire
Рет қаралды 98 М.
Programming the PIC16F84A in C with MPLAB X
14:19
James Smith
Рет қаралды 58 М.
PIC MCU DEBUGGING #1 - Basic info & Example (Absolute Beginner)
15:48
Interrupts in PIC Microcontrollers | PIC18F External interrupts
15:07