Interrupts 🔴 PIC Microcontroller Programming Tutorial #5 MPLAB in C

Поделиться
HTML-код
  • Опубликовано: 17 окт 2024

Комментарии • 61

  • @BinderTronics
    @BinderTronics  4 года назад +9

    Full playlist on the PIC microcontroller Programming ruclips.net/video/KSI6fzOPVz0/видео.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.

  • @elless317
    @elless317 7 месяцев назад

    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  7 месяцев назад

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

    • @elless317
      @elless317 7 месяцев назад +1

      @@BinderTronics mmmh, interesting. Thanks for the reply

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

  • @willashland4597
    @willashland4597 3 года назад +1

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

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

  • @luke2v52
    @luke2v52 2 года назад

    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  2 года назад +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.

  • @lukagacnik3093
    @lukagacnik3093 3 года назад +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  3 года назад +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.

  • @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.
      ruclips.net/video/ePyTYILiAzI/видео.html

    • @Syeda-Hadia
      @Syeda-Hadia Год назад

      @@BinderTronics such a great 👍, thank you very much 🙂

  • @LeonardCotrimFreundl
    @LeonardCotrimFreundl 6 месяцев назад

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

    • @LeonardCotrimFreundl
      @LeonardCotrimFreundl 6 месяцев назад

      ...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  6 месяцев назад

      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 6 месяцев назад +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

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

  • @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 года назад

      ruclips.net/video/pPmEWlIYByo/видео.html
      ruclips.net/video/O4IpwgWhqLY/видео.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.

  • @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 ruclips.net/video/E-UMOx7qv2k/видео.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.

  • @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 года назад

      ruclips.net/video/LYPaOXhvXWk/видео.html
      Mode swap section. Same idea.

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

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

  • @stanholmes4293
    @stanholmes4293 4 года назад +1

    Hi
    Excelent explination on interrupts

  • @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 RUclips 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.
      ruclips.net/video/aQy3DGSIGm4/видео.html
      ruclips.net/video/Zjv3fNCcVsI/видео.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.

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

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

      ruclips.net/video/LYPaOXhvXWk/видео.html have fun.

  • @aheletcodefloppydevice.2196
    @aheletcodefloppydevice.2196 4 года назад +1

    very good

  • @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 года назад +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💯