> -----Original Message----- > From: Thomas N [SMTP:thomasn101@HOTMAIL.COM] > Sent: Thursday, November 28, 2002 6:12 AM > To: PICLIST@mitvma.mit.edu > Subject: Re: [PIC]: SPI protocol > > Thank you for your comments! > > When you write data to SSPBUF, how do you know when the data transmision > is completed? The only way to know this is thru interrupt. If I send 2 > bytes of data, interrupt will happen 2 times. How do I know which > interrupt is the second interrupt(when the second byte is sent)? > > Regards, > Thomas > The SSPIF bit is set when the byte in SSPBUF has been transmitted, but there is no requirement for this to fire an interrupt. You can simply mask off the MSSP interrupt (SSPIE = 0) and poll the SSPIF bit in a loop. If you really want to use interrupts, then you will have to make some arrangement so the ISR knows how many bytes it needs to send. When sending data on the SPI, set a counter holding the number of bytes to send. After sending each byte, the counter can be decremented in the ISR until it is zero. Regards Mike -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads