Interrupts 🔴 PIC Microcontroller Programming Tutorial #5 MPLAB in C

  Рет қаралды 27,287

Binder Tronics

Binder Tronics

Күн бұрын

Пікірлер: 61
@BinderTronics
@BinderTronics 5 жыл бұрын
Full playlist on the PIC microcontroller Programming kzbin.info/www/bejne/gYSsZ5mwhLWJsJI Under compiler XC8 v2.00 and up the ISR functions change to: - #include - void __interrupt() high_isr(void); - void __interrupt(low_priority) low_isr(void); Credit to user Peng of for informing me of this.
@mracipayam
@mracipayam 3 жыл бұрын
I was gonna write this, i did not see this explanation first , thanks.
@L2.Lagrange
@L2.Lagrange 3 жыл бұрын
Hey man I really appreciate you making this series. I will be referencing it many times over the next few months during my UMN EE microcontrollers class!
@BinderTronics
@BinderTronics 3 жыл бұрын
Glad to hear it is of some use.
@L2.Lagrange
@L2.Lagrange 2 жыл бұрын
*
@muhammadfaizan8839
@muhammadfaizan8839 5 жыл бұрын
nice Explanation sir. please make more video on interrupt examples.
@BinderTronics
@BinderTronics 5 жыл бұрын
One releasing the 4th Feb
@willashland4597
@willashland4597 3 жыл бұрын
Great videos and love your accent mate. Are you South African?
@BinderTronics
@BinderTronics 3 жыл бұрын
Yeah from the other down under.
@elless317
@elless317 9 ай бұрын
Hello. Thanks for video. Can you tell me the benefit of using interrupts instead of doing the same just with normal digital inputs? Thanks
@BinderTronics
@BinderTronics 9 ай бұрын
Polling can miss the input and it is slower at reading the input. Interrupts are clock independent and will latch until serviced.
@elless317
@elless317 9 ай бұрын
@@BinderTronics mmmh, interesting. Thanks for the reply
@luke2v52
@luke2v52 3 жыл бұрын
I have been enjoying this playlist so far, but I have two questions. 1. Around 6:51, you use INT1E and INT1P instead of INT1IE and INT1IP like the datasheet says. Is that like a shorthand that means the same thing? 2. What is the purpose of using low priority vs high priority in this example? In both cases they did the same task. I believe this only matters when both buttons are pressed since the high priority would be the only LED on, but is this the case or no? I apologize if you mentioned this already, but after swiping through the video a few times, I could not find this addressed.
@BinderTronics
@BinderTronics 3 жыл бұрын
1. Same thing. Have a look in the pic18f4520.h file. The bit fields should be at the same address in a union. 2. "in this example" It severs only the purpose of showing the assignment to the low priority vector interrupt. You are overthinking it. if you really want to look into it. This is the simplest way of testing that both the interrupt vector priority are working.
@stanholmes4293
@stanholmes4293 4 жыл бұрын
Hi Excelent explination on interrupts
@mrafayshams3089
@mrafayshams3089 Жыл бұрын
If we want to have the INT2 interrupt, will we need to add another isr or will need another if statement in the high_isr(){...} ?
@BinderTronics
@BinderTronics Жыл бұрын
Another if statement in the high_isr(){...}
@mrafayshams3089
@mrafayshams3089 Жыл бұрын
I get an error: variable has incomplete type 'void' when I try to name the isr function as void interrupt highISR(void). How to find what is a way to name the ISR function?
@BinderTronics
@BinderTronics Жыл бұрын
Did you read the pined comment? onlinedocs.microchip.com/pr/%20GUID-BB433107-FD4E-4D28-BB58-9D4A58955B1A-en-US-1/index.html?GUID-2AC0BB59-9083-4213-A961-F40BE6B91AF6
@lukagacnik3093
@lukagacnik3093 4 жыл бұрын
Can you explain, why does "GIEL" and "GIEH" need to be set HIGH in the main code? Great video by the way! :)
@BinderTronics
@BinderTronics 4 жыл бұрын
GIEH enables the high priority interrupt. No interrupt will trigger before GIEH is set. GIEL enables the low priority interrupts. GIEL only disables the low priority interrupts.
@TomTom-ty5ej
@TomTom-ty5ej 5 жыл бұрын
Hi, Great job! Is it possible to put in e.g.--- __delay_ms(200);---- to somewhere to avoid debouncing? Thanks!
@BinderTronics
@BinderTronics 5 жыл бұрын
Just not inside the interrupt. It is bad practice to have any blocking code in an interrupt. I do have an example of doing debouching in kzbin.info/www/bejne/e164foKubNapaM0. To make it work (the easy way) you just have to move the if(!button_press){ section to the interrupt and remove the inner if(). The hard way disabling the interrupt and re-enabling it when the timer expires.
@aheletcodefloppydevice.2196
@aheletcodefloppydevice.2196 4 жыл бұрын
very good
@littlekarthick3402
@littlekarthick3402 3 жыл бұрын
Hi , Do some example program ON LED blinking continuously after one press on the button and OFF LED blinking after one press on the button.
@BinderTronics
@BinderTronics 3 жыл бұрын
kzbin.info/www/bejne/goqzkoKOnduLjc0 Mode swap section. Same idea.
@LeonardCotrimFreundl
@LeonardCotrimFreundl 9 ай бұрын
But how does the PIC know where there is going to be a rising/falling Edge?
@LeonardCotrimFreundl
@LeonardCotrimFreundl 9 ай бұрын
...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?
@BinderTronics
@BinderTronics 9 ай бұрын
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
@LeonardCotrimFreundl
@LeonardCotrimFreundl 9 ай бұрын
@@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
@DanielCharry1025
@DanielCharry1025 4 жыл бұрын
Outstanding tutorial. It would be nice to have a parallel one on mpasm though. Bravo!
@BinderTronics
@BinderTronics 4 жыл бұрын
I have been playing with the idea of making a series on assembler. The thing is that it is not used in the industry very much. Only in very niche cases is it used. It is by far much better to disasmble C code and then lookup the instructions that the code is generating. The other question is what assembler flavor should I use.
@StoriesoftheSoul1018
@StoriesoftheSoul1018 2 жыл бұрын
Hi, Sir I just need ur help I hope u will be biggest help sir I'm currently doing a project in which I'm interfacing pic16F877a microcontroller with Max7219 dot matrix module. Can u guide me sir regarding this Regards
@BinderTronics
@BinderTronics 2 жыл бұрын
What you are looking for is how to multiplex. This covers 99% of what you need to know. kzbin.info/www/bejne/m4HchYx_gc50sKs
@StoriesoftheSoul1018
@StoriesoftheSoul1018 2 жыл бұрын
@@BinderTronics such a great 👍, thank you very much 🙂
@sailfromsurigao
@sailfromsurigao 4 жыл бұрын
Hi, I tried simulating the circuit in proteus and loaded the hex file of the code but LED's are not turning on. Please help
@sailfromsurigao
@sailfromsurigao 4 жыл бұрын
It says in the proteus that "MCLR is low. Processor is in reset". But when I tried to put a VDD on the MCLR pin, LED's are still not turning on
@ShahbazParviezQazi
@ShahbazParviezQazi 3 жыл бұрын
@@sailfromsurigao use +5V
@sailfromsurigao
@sailfromsurigao 4 жыл бұрын
Hi, i added delays as debouncing. But I'm getting an error of "interruptsmain.c:12:6: error: variable has incomplete type 'void' void interrupt high_priority high_isr(void)"
@sailfromsurigao
@sailfromsurigao 4 жыл бұрын
I read you comment. Got it thanks
@prashantiprao7492
@prashantiprao7492 4 жыл бұрын
Have you got answer to this question?
@vaibhavkapadia1
@vaibhavkapadia1 3 жыл бұрын
@binder tronics sir i am using PIC18F47Q10 for my project i am currently facing an issue that my main function is repeating itself infinitely i am using internal oscillator at 8MHZ and beside this i am not able to use interrupts i have set all the bits required for generating interrupt but i am not able to use interrupt flag for Rx and Tx in EUSART please guide me
@BinderTronics
@BinderTronics 3 жыл бұрын
kzbin.info/www/bejne/poHQdoqifr51r9E kzbin.info/www/bejne/hWWsoaqdjM2kgrs Is your uart sending data out on the TX PIC->PC? Don't bother with the interrupt on the uart until the above is working. Run it in simulator and double check that the bits are set that are supposed to be.
@vaibhavkapadia1
@vaibhavkapadia1 3 жыл бұрын
@@BinderTronics it is transmitting the data but my problem is that my void main() function is repeating itself infinitely without any infinite loop .
@BinderTronics
@BinderTronics 3 жыл бұрын
You must have a at least 1 infinite loop in the main function. Your program counter is overflowing.
@learner_analog
@learner_analog 3 жыл бұрын
@@BinderTronics I want to show you my code ,its just a simple led blinking circuit without any infinite loop , main function is executing infinitely can you share your email id so that i can send you my code
@BinderTronics
@BinderTronics 3 жыл бұрын
Here is what you do. Make a github account. Create a new public repo. Upload you code there. Post the link here. I'll give it a look and give you a price estimate.
@lunakomsomi6418
@lunakomsomi6418 5 жыл бұрын
Hi, I am looking for a simple code to increment a counter each time the switch is pressed.
@BinderTronics
@BinderTronics 5 жыл бұрын
kzbin.info/www/bejne/goqzkoKOnduLjc0 have fun.
@toysandgames7015
@toysandgames7015 2 жыл бұрын
Can pic18's family do everything, including motor control, because I have seen pic 32 of a university, its applications are so great that I'm bewildered. , I watch the project about pic 32 via Bruce Land's KZbin channel
@BinderTronics
@BinderTronics 2 жыл бұрын
It can most likely do what you want it to do. You have to select a MCU based on your needs. This PIC can do motor control for a single motor. If a MCU can generate a PWM signal it can do motor control. The AVR atmega328p are much better at it and the king of motor control is the STM32G series. Here is what you want to research. kzbin.info/www/bejne/l4LcZHd9iK56o5Y kzbin.info/www/bejne/kJvZZJmEeMiJqas 1 PWM signal, speed control. 1-4 PWM signals, speed and direction (H-bridge). 1 PWM + ECU module, control a BLDC motor. 3 PWM signals, direct BLDC and 3 phase motors. Recommend looking at what the hobby RC communities are using rather than looking at university lectures. Side note I have only seen a PIC used in a industrial/consumer application once.
@mendupmindcode1736
@mendupmindcode1736 3 жыл бұрын
sir i am watching your tutorial and i learned alot but sir i wana request please do obstacle avoidnes robot with atmega328p i write code and now i am facing issue its not working if you can do it please it will be so help and it will cover alot of topic
@BinderTronics
@BinderTronics 3 жыл бұрын
Lookup hc-sr04 arduino
@mendupmindcode1736
@mendupmindcode1736 3 жыл бұрын
@@BinderTronics sir i yep i got the distance from hc-sro4 but the main issue when distance is than 20 robot stop and hen i want that servo motor rotate the hc-sro4 to lef -90" and get left distance and the to right to get the right distance and then it decide which distcance is more and robot move in that irection but the main issue i got with servo motor sir if you kindly do it it will be great a great tutorial for us hence it will cover alot of topic
@keydarkman
@keydarkman 6 жыл бұрын
you could zoom in on the screen to see the code.
@BinderTronics
@BinderTronics 6 жыл бұрын
What type of device are you watching on? Looks fine on a 22" screen @ 1080p but will make some adjustments. You can also have a look at the Git repo.
@keydarkman
@keydarkman 6 жыл бұрын
@@BinderTronics only do it zoom to the code.
@kaumohlamonyane272
@kaumohlamonyane272 3 жыл бұрын
The accent sounds South African
@BinderTronics
@BinderTronics 3 жыл бұрын
Cause it is one.
@BinderTronics
@BinderTronics 3 жыл бұрын
@@kaumohlamonyane272 Suggest you remove your university and subject code from your comment.
@kaumohlamonyane272
@kaumohlamonyane272 3 жыл бұрын
@@BinderTronics Thanks for that💯
Lecture 9: Interrupts
20:43
Embedded Systems and Deep Learning
Рет қаралды 273 М.
Build an Arduino EEPROM programmer
57:30
Ben Eater
Рет қаралды 1,6 МЛН
Interrupts in PIC Microcontrollers
18:13
Ricky Castles
Рет қаралды 6 М.
20022 FRM2 - Begin Programming a PIC16F1xxx in C Like a Pro
2:01:39
Microchip Technology, Inc.
Рет қаралды 137 М.
How does a USB keyboard work?
34:15
Ben Eater
Рет қаралды 3,3 МЛН
ТЕЛЕФОН МЕНЯЕТ ЦВЕТ😅 #upx
0:34
RanF
Рет қаралды 639 М.
shocking end 🥴🤯 LeoNata family #shorts TikTok
0:54
LeoNata Family
Рет қаралды 41 МЛН
(✋❌)kageihina VS siajiwoo VS meosimmyyt VS oxzung#tiktok #shorts
0:12
Это лютый угар 🤣 | приколы Арсен Симонян
0:14
Арсен Симонян
Рет қаралды 294 М.