Thank you for your advice. I will try this and see what happens! thanks again, thomas >From: Michael Rigby-Jones >Reply-To: pic microcontroller discussion list >To: PICLIST@MITVMA.MIT.EDU >Subject: Re: [PIC]: SPI routine for 16F84 slave mode >Date: Mon, 23 Apr 2001 08:11:46 +0100 > >3 wire slaves (such as SPI) detect the state of the data line on either the >falling or rising edge, so you shouldn't need a delay in your interrupt >handler. The state of the data should be stable when the clock edge is >detected. > >You don't need to have a timeout, a 3 wire bus uses a Chip Select (CS) >line. >In your interrupt service routine you can read the state of the CS line, >and >if it is active (usualy active low) then shift in your data. If it is not >then reset you shift register routine. This way, if a transmission is >aborted part way through, you won't be left with half of the data in your >shift register. > >If you decide to use polling instead of interrupts, this will either >severely limit your maximum bus speed or what else you can do at the same >time. > >Regards > >Mike > > > -----Original Message----- > > From: Thomas N [SMTP:thomasn101@HOTMAIL.COM] > > Sent: Monday, April 23, 2001 7:27 AM > > To: PICLIST@MITVMA.MIT.EDU > > Subject: [PIC]: SPI routine for 16F84 slave mode > > > > Hi everyone, > > > > I wrote a SPI routine for the 16F84 master mode only before and it works > > great. I am stuck at writing the SPI routine for the 16F84 slave mode. > > > > I don't want to write the code with clock frequency-dependant (I mean I > > don't want fixed input clock frequency). > > > > I was thinking of detecting the level change (use interrupt?), delay a > > little bit, and take the sample. But "delay a little bit" limit the >input > > frequeny. And what if the master stops in the middle of the >transmition? > > The way I wrote the code, it will stuck (keep waiting for the master to > > send > > enough clock cycle - it expects 8 bits before the subroutine exits) I >am > > not sure how to write the timeout routine. > > > > Please help me or give me a link to the SPI routine (I searched at > > piclist.com, but couldn't find anything useful). It would be ideal if > > there > > is a code which can do both transmit and receive (master or slave mode)! > > > > Thank you in advance > > Thomas > > > > >_________________________________________________________________________ > > Get Your Private, Free E-mail from MSN Hotmail at >http://www.hotmail.com. > > > > -- > > http://www.piclist.com hint: The list server can filter out subtopics > > (like ads or off topics) for you. See http://www.piclist.com/#topics > > > > > >-- >http://www.piclist.com hint: The list server can filter out subtopics >(like ads or off topics) for you. See http://www.piclist.com/#topics > > _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics