Hello Gerhard, I am using PICC-18 8.35, but I would like to avoid declaring reentrant procedures. It's so nasty that the interrupt triggering for CAN is different from that for UART. For UART, when I would enable the TXIE interrupt, I would know that the ISR would be called immediately, because the TX buffer was empty. For CAN it is different. So there is not a *standard* way of treating this kind of interrupt ? Regards, Lucian Gerhard Fiedler wrote: >Gerhard Fiedler wrote: > > > >>Lucian Copat wrote: >> >> >> >>>void CANSendMessage() { >>> >>> //fill the 100-byte buffer >>> >>> while (CANPut()); >>>} >>> >>>In the ISR I have: >>> >>>if (can TX interrupt) { >>> while (CANPut()); >>>} >>> >>>Until here am I correct ? >>> >>> >>Basically, yes. >> >> > >Well, no :) > >void CANSendMessage() { > make sure there's data to send > (possibly lock the data buffer) > > wait until CAN tx int is disabled > (or return with an error if it is enabled) > > make sure CAN tx is set up correctly > and enable CAN tx int > > CANPut(); // assemble CAN msg and put in buffer >} > >void ISR() >{ > if (can TX interrupt) { > if (!CANPut()) // returns 0 if no more data to send > disable CAN tx int > } >} > > >There are some details that depend on the rest of the app, but this should >work, somehow... :) > >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