PIC XC8 HTC.h and __delay_ms()

Thread Starter

odm4286

Joined Sep 20, 2009
243
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!
 

ErnieM

Joined Apr 24, 2011
8,053
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.
 

Thread Starter

odm4286

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

JohnInTX

Joined Jun 26, 2012
4,198
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?
 

Thread Starter

odm4286

Joined Sep 20, 2009
243
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?
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).

What does the compiler manual say about it?
Thanks, guess I should RTFM lol. It was in the xc8 compiler doc.
 
Top