View previous topic :: View next topic |
Author |
Message |
grasspuddle
Joined: 15 Jun 2006 Posts: 66
|
delay_ms not delaying |
Posted: Thu Jun 15, 2006 12:49 pm |
|
|
when i put in delay_ms() code i have no delay
my use command:
Code: |
#use delay(clock=4000000)
|
i also get the 'Interrupts disabled during call to prevent re-entrancy:' warning, but when i comment every delay I have, it only removes one of the warnings, i still have 3 more. all warnings point to the last line of my main code.
my code is basically:
send command
wait n seconds to fill serial buffer
read off buffer etc.
interrupts work, and when i first entered the delay_ms command it did work
what more info should i put? anyone have this problem? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jun 15, 2006 1:12 pm |
|
|
If you feel that you must put a delay inside an isr, and you don't
want to see that warning message, then tell the compiler to create
a 2nd instance of the delay library by adding a 2nd #use delay()
statement as shown in bold below. That way, the isr and the
code in main() (and beyond) will each have their own separate
delay routines.
Quote: | #include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, NOBROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
#int_ext
void int_ext_isr(void)
{
delay_ms(1);
}
#use delay(clock = 4000000)
//======================
void main()
{
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
while(1)
{
printf("Hello World\n\r");
delay_ms(100);
}
}
|
|
|
|
grasspuddle
Joined: 15 Jun 2006 Posts: 66
|
|
Posted: Thu Jun 15, 2006 1:30 pm |
|
|
i don't have a delay_ms inside the interrupt, its in a function
i have also commented out all delay_ms commands and still get the warnings
i would like to know why i still get them |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jun 15, 2006 1:35 pm |
|
|
There must be some function that you're calling from inside the isr
and outside as well. It would help if you could post a small but
complete test program. |
|
|
grasspuddle
Joined: 15 Jun 2006 Posts: 66
|
|
Posted: Thu Jun 15, 2006 2:05 pm |
|
|
recopied all of the code into a new project and that seems to of cleared up the warnings...
it now works |
|
|
|