PIC XC8 HTC.h and __delay_ms()

Discussion in 'Embedded Systems and Microcontrollers' started by odm4286, Mar 20, 2016.

  1. odm4286

    Thread Starter Active Member

    Sep 20, 2009
    155
    5
    Hello all, I'm not too familiar with this function but I know its just a loop to "stall" the processor for a given amount of time. My question is, are interrupts available while this function is running, or does __delay_ms() take precedence? Thanks!
     
  2. dannyf

    Well-Known Member

    Sep 13, 2015
    1,819
    362
    What does the compiler manual say about it?
     
  3. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,392
    1,605
    99% sure it is a simple dumb delay so interrupts will fire.

    No telling what that does to the delay time though... Probably extends them some.
     
  4. odm4286

    Thread Starter Active Member

    Sep 20, 2009
    155
    5
    Turns out its just a loop of NOP commands. Also found out its supported directly by XC8 so no need for HTC.h anymore
     
  5. JohnInTX

    Moderator

    Jun 26, 2012
    2,347
    1,029
    You can use the dumb delay routines with interrupts in your code. As ErnieM observes, the timing will be longer than indicated because the dumb delay calculations assume that they have sole control of the CPU. If you are using interrupts, why not dedicate one of the timers to generate system delays?
     
  6. odm4286

    Thread Starter Active Member

    Sep 20, 2009
    155
    5
    Short answer, it's only for a school project and I just want to get it done as quickly as possible. I may use timer interrupts for a few sections, if it goes smoothly I'll even use interrupts for the non-critical stuff(flashing LEDs).

    Thanks, guess I should RTFM lol. It was in the xc8 compiler doc.
     
  7. dannyf

    Well-Known Member

    Sep 13, 2015
    1,819
    362
    That's the point - it gets you to the most authoritative answer and you learn to how to answer all future questions on the compilers.

    Killing two birds with one stone.
     
    odm4286 likes this.
Loading...