As usual, this list offers excellent advice. On Mon, 30 Oct 2000, Chris Eddy wrote: > When you share a buffer, or a flag, or any other variable between main line > code and an interrupt, get in the habbit of declaring it volatile. This is > especially useful for int types, where accessing a multipart variable > simultaneously would cause gross errors. This one is a subtle one, you might > read up on it. 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. 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? In more general terms, Chris and others warn me away from sharing executable code between int and main line code. Point taken. Any comments on sharing variables between int and main line code? I understand that the goal is to close any opportunity for a variable to change after you test it but before you act upon it, and then to take the wrong action. 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: > > > Hi Gang, > > > > Quick question: > > > > 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? -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics