>-----Original Message----- >From: Jinx [mailto:joecolquitt@CLEAR.NET.NZ] >Sent: 25 June 2004 14:02 >To: PICLIST@MITVMA.MIT.EDU >Subject: Re: [PIC:] MSSP module > > >> > bcf pir1,sspif >> > mov 0x55,sspbuf ;send data >> > btfsc pir1,sspstat,r_w >> > bra $-2 > >> I'm a little surprised that this works > >And you'd be right. I did spot that it was not the same as >the original .asm. pir1,sspif is what it should be > >I tried it just out of interest, and btfsc pir1,sspstat,r_w >actually compiles to btfsc pir1,pspif. Which doesn't work > >Anyway, apart from that little hiccup, look OK ? You know, I hadn't even spotted that there were three operands! The point I was really trying to make was about the next section of code that waits for sspif to be set: (my comments) bcf pir1,sspif ; clear interrupt flag mov 0x55,sspbuf ; load SSPBUF with data to be sent btfsc pir1,sspif ; wait for data to be sent bra $-2 ; data not sent, keep checking At this point the PIC has clocked the ACK bit in, RW will be clear and SSPIF will be set bcf pir1,sspif ; clear interrupt flag btfss pir1,sspif ; is interrupt flag set? bra $-2 ; not yet, keep trying The last three instructions would seem (to me) to cause an endless loop. The PIC has set the interrupt flag when the data has been clocked out and the ACK bit clocked in. You then clear the interrupt flag and wait for it to be set again, but with nothing in SSPBUF that interrupt is not going to happen. I may be missing something... Regards Mike ======================================================================= This e-mail is intended for the person it is addressed to only. The information contained in it may be confidential and/or protected by law. If you are not the intended recipient of this message, you must not make any use of this information, or copy or show it to any person. Please contact us immediately to tell us that you have received this e-mail, and return the original to us. Any use, forwarding, printing or copying of this message is strictly prohibited. No part of this message can be considered a request for goods or services. ======================================================================= Any questions about Bookham's E-Mail service should be directed to postmaster@bookham.com. -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads