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 -----Original Message----- From: pic microcontroller discussion list [mailto:PICLIST@MITVMA.MIT.EDU] On Behalf Of Bob Axtell Sent: Wednesday, November 27, 2002 8:45 PM To: PICLIST@MITVMA.MIT.EDU Subject: Re: [PIC]: SPI protocol > I have some problems with the project I am working on, and I need your > help! > > 1. I have 2 devices on the SPI bus (one 16-bit and one 8-bit). > Each device has its own Chip Select signal. What I want to do is: > > For 16-bit device > Select the chip > Send 16 bits of data > Deselect the chip > > For 8-bit device > Select the chip > Send 8 bits of data > Deselect the chip > > I have no problem writing the code for multiple 8-bit devices, but when > it comes to a mixture of 8-bit and 16-bit devices, I am totally stuck. > I am thinking of using a variable in the ISR to indicate whether it is a > 8-bit or 16-bit device, but I think it needs Mutual Exclusion. I am > using the 16F877. Please help! Unless the chip is selected, whatever happens on the clock and data lines means nothing. [16b]: Just select that chip, send the first byte/capture data out, then send the second byte/capture data out, then deselect the chip. [8b]: Just select the chip, send the byte/capture data out, then deselect the chip. > 2. The SPI module on the 16F877 can be configured to run at > different speed. Don't we always want to run it at the fastest speed? Not quite true. Some SPI devices cannot have a clock faster than 1Mhz or even 400Khz. At 20Mhz, the fastest SPI is 4Mhz. > Thank you for your help! > Best regards, > Thomas > > -- > http://www.piclist.com hint: To leave the PICList > mailto:piclist-unsubscribe-request@mitvma.mit.edu > > > -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads