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 -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist