See my insertions below. Frank -----Original Message----- From: Michael Shiloh [mailto:mshiloh@MEDIABOLIC.COM] Sent: Tuesday, October 31, 2000 12:56 AM To: PICLIST@MITVMA.MIT.EDU Subject: [PIC]: Re: function calls from isr? > As I understand it, the "volatile" keyword is used to tell the compiler > that a variable might change without it knowing about it. This is to > warn the compiler that just because no code has changed the variable, it > doesn't mean that the variable won't change; otherwise, an optimizing > compiler might optimize out some code. > > This is often used when the variable represents a hardware register. This is correct. > My compiler (C2C) doesn't support the volatile keyword, so I guess I > should either turn off optimization or look carefully at the generated > assembly code and make sure that when volatile registers are read they > really are read from hardware. > > Does this sound about right to you? At end of your development, you can turn on optimization and look again. > My original question is below. I should point out that this is for > the transmitter, so the program is putting chars on the buffer, and > the ISR is taking them off and feeding them to TXREG whenever a TXIF > occurs: > > I'm using the C2C compiler with a 16C63. I'm writing some code > > around an interrupt driven serial port using the on-board USART. > > I use a circular buffer to queue characters for transmission. > > > > I have a function to remove a character from the buffer, and I > > call this from both an ISR and main code, and I get a warning > > for doing so: > > > > Warning: Function '_SerTxBufferRemove' used both in interrupt and main code > > > > Is it not permitted to call a function from both interrupt code > > and main code? I don't understand, why you are using this function from main(). AFAIK the only reason for this is to reject your previous char insertion. But at this time you don't know wether the character has been sent by the isr() or not. I include one interesting mail from the hitech list. I don't know if the compiler handling is the same on C2C. >> guess what I'm asking is:are there any conditions were calling the same >> function from main() and an ISR is acceptable from the compilers POV? > >Yes, if the function uses no local variables in RAM. -- GSP Sprachtechnologie GmbH Teltowkanalstr.1, D-12247 Berlin Tel.: +49 (0)30 769929-0 Fax: +49 (0)30 769929-12 eMail: Info@gsp-berlin.de Web: http://www.gsp-berlin.de -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.