Interrupts 🔴 PIC Microcontroller Programming Tutorial #5 MPLAB in C

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 พ.ย. 2024

ความคิดเห็น • 61

  • @BinderTronics
    @BinderTronics  5 ปีที่แล้ว +9

    Full playlist on the PIC microcontroller Programming th-cam.com/video/KSI6fzOPVz0/w-d-xo.html
    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 ปีที่แล้ว +1

      I was gonna write this, i did not see this explanation first , thanks.

  • @L2.Lagrange
    @L2.Lagrange 3 ปีที่แล้ว +1

    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!

  • @muhammadfaizan8839
    @muhammadfaizan8839 4 ปีที่แล้ว +4

    nice Explanation sir. please make more video on interrupt examples.

  • @stanholmes4293
    @stanholmes4293 4 ปีที่แล้ว +1

    Hi
    Excelent explination on interrupts

  • @willashland4597
    @willashland4597 3 ปีที่แล้ว +1

    Great videos and love your accent mate. Are you South African?

    • @BinderTronics
      @BinderTronics  3 ปีที่แล้ว

      Yeah from the other down under.

  • @DanielCharry1025
    @DanielCharry1025 4 ปีที่แล้ว

    Outstanding tutorial. It would be nice to have a parallel one on mpasm though. Bravo!

    • @BinderTronics
      @BinderTronics  4 ปีที่แล้ว +1

      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.

  • @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

  • @aheletcodefloppydevice.2196
    @aheletcodefloppydevice.2196 4 ปีที่แล้ว +1

    very good

  • @elless317
    @elless317 8 หลายเดือนก่อน

    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  8 หลายเดือนก่อน +1

      Polling can miss the input and it is slower at reading the input. Interrupts are clock independent and will latch until serviced.

    • @elless317
      @elless317 8 หลายเดือนก่อน +1

      @@BinderTronics mmmh, interesting. Thanks for the reply

  • @lukagacnik3093
    @lukagacnik3093 4 ปีที่แล้ว +1

    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 ปีที่แล้ว +1

      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.

  • @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(){...}

  • @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 ปีที่แล้ว

      th-cam.com/video/LYPaOXhvXWk/w-d-xo.html
      Mode swap section. Same idea.

  • @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

      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.

  • @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 TH-cam 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.
      th-cam.com/video/aQy3DGSIGm4/w-d-xo.html
      th-cam.com/video/Zjv3fNCcVsI/w-d-xo.html
      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.

  • @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)"

  • @Syeda-Hadia
    @Syeda-Hadia ปีที่แล้ว

    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  ปีที่แล้ว

      What you are looking for is how to multiplex.
      This covers 99% of what you need to know.
      th-cam.com/video/ePyTYILiAzI/w-d-xo.html

    • @Syeda-Hadia
      @Syeda-Hadia ปีที่แล้ว

      @@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

  • @LeonardCotrimFreundl
    @LeonardCotrimFreundl 7 หลายเดือนก่อน

    But how does the PIC know where there is going to be a rising/falling Edge?

    • @LeonardCotrimFreundl
      @LeonardCotrimFreundl 7 หลายเดือนก่อน

      ...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  7 หลายเดือนก่อน

      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 7 หลายเดือนก่อน +1

      @@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

  • @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 th-cam.com/video/E-UMOx7qv2k/w-d-xo.html. 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.

  • @vaibhavkapadia1
    @vaibhavkapadia1 2 ปีที่แล้ว

    @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  2 ปีที่แล้ว

      th-cam.com/video/pPmEWlIYByo/w-d-xo.html
      th-cam.com/video/O4IpwgWhqLY/w-d-xo.html
      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 2 ปีที่แล้ว

      @@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  2 ปีที่แล้ว

      You must have a at least 1 infinite loop in the main function. Your program counter is overflowing.

    • @learner_analog
      @learner_analog 2 ปีที่แล้ว

      @@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  2 ปีที่แล้ว +1

      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 ปีที่แล้ว +1

      th-cam.com/video/LYPaOXhvXWk/w-d-xo.html have fun.

  • @mendupmindcode1736
    @mendupmindcode1736 2 ปีที่แล้ว

    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  2 ปีที่แล้ว

      Lookup hc-sr04 arduino

    • @mendupmindcode1736
      @mendupmindcode1736 2 ปีที่แล้ว

      @@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

  • @kaumohlamonyane272
    @kaumohlamonyane272 3 ปีที่แล้ว +1

    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💯

  • @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.