I know that a message has at maximum 8 bytes in CAN, that's why I need to develop my own higher layer protocol to fragment the data. But when the interrupt is enabled, it doesn't activate if the buffer is empty, but when the buffer becomes empty (after having sent a CAN message). In this way, I can only avoid reentrance by writing the same code twice or by setting a flag in the interrupt. Lucian Gerhard Fiedler wrote: >Lucian Copat wrote: > > > >>My question regards the E-CAN module in PIC18F4680. I have a routine >>which loads a message (100 bytes max) into a temporary sending buffer. >> >> > >You know that a single CAN message can only have 8 bytes payload, right? > > > >>I would like that after loading this buffer, when I activate the TX >>interrupts, the ISR to be called if there are some free buffers. E-CAN >>module does generate an interrupt only when a buffer _becomes_ empty, >>which means I should load it first. If I load it first and also in ISR, >>I would have reentrant code. Is there any method to pass this problem ? >> >> > >You would typically disable the TX interrupt in the ISR when it sees that >there are no more bytes. Then, after initiating the next tx sequence, you >reenable it. This way, there's no problem with reentrance. > >Gerhard > > > -- *Lucian Copat Software Team Leader Audiotel Comlabs E-mail: lucian.copat@audiotel.ro Mobile: (+4)0722.729.658 Web: http://www.audiotel.ro* -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist