At 07:01 PM 18/06/98 EDT, you wrote: >Hello everyone- thanks for tolerating and providing help with the ongoing saga >of my serial problems. > >In summary, I am having difficulty getting a PIC serin and serout program to >work together. They both work if I run them independently, by commenting out >the jump to the other routine. > >In the latest attempt to solve the serial blues I've encountered I added an >additional handshake line to provide a PIC output to tell the BS2 when it is >ready for serin data. I did use the BSF/BCF on portb,5 to send this command. I >think that the BCF/BSF commands are messing with my port states. When I run >this program my BS2 timesout on both the serin and serout. I did find a >problem in that once I set the _INSHAKE line high it doesn't go low. I added a >BCF instruction at all the exit points of the serin routine and the _INSHAKE >line still stays high all the time. If I reset the PIC it has a 50/50 chance >of being high or low all the time. I am going crazy about now. I don't know >why this part of the code is so difficult for me. > >I found a reference in a book I have by Mike Predko that talks about the >problem using BSF and BCF that a read takes place and if the line is pulled >high via another device, it will be set high after the read takes place. I >believe that exactly what one of my problems may be. I am not sure what the >simpliest way is to solve this problem because I use the BSF/BCF instruction >throughout the PIC serout routine which is timing sensitive. > >Am I to understand using the MOVLW AND MOVWF PORT,B or the AND (other) command >will not inadvertently alter the pin states? > >Should I rewrite all my routines to eliminate BSF/BCF instructions? > >What is the most efficient way to alter a single output line? For example if I >want to set portb,5 high what instructions can do this efficiently without >altering the other pin states? Maybe the AND command? Could someone provide an >example? > >By the way I am not sure what the term "bit banging" means. I think it means >bit manipulation using instructions such as RRF,RLF, AND, OR etc. and not MOV >or SWAP etc. Am I correct? > >Thanks > > Yes you have hit the nail on the head, BSF and BCF on a port are read write modify instructions in most porcessors i.e. They read the entire byte (Be this a port or a register), set or clear the bit and then write the byte back, but this is only a problem when you mix inputs and outputs (Normaly). If the pin is programmed as an output, the code will (In most processors) read the state of the write latch, however some do read the actual pin state. If I recall (Don't have a data book handy) the PIC will just change the state of the required pin and leave the others alone. ie. The PIC has boolean instructions and processing abilities However your AND type response is not the way to go, as it must read the state of all the pins (In and out) and then you write the result back. BSF PORTB,5 is the simplest way to set the pin Bit baning is just a name for sending out serial data bit by bit in software Quite simply I think that your problem is elsewhere Dennis -=====================================================================- Dennis Plunkett: Embedded Hardware, Software design NEC Australia ph 03 9264-3867 -=====================================================================-