Searching \ for 'Serial Blues Continued' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/io/serials.htm?key=serial
Search entire site for: 'Serial Blues Continued'.

Truncated match.
PICList Thread
'Serial Blues Continued'
1998\06\18@232710 by

picon face
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

1998\06\19@020635 by Dennis Plunkett

flavicon
face
At 07:01 PM 18/06/98 EDT, you wrote:
{Quote hidden}

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

-=====================================================================-

1998\06\19@065155 by Caisson

flavicon
face
> Van: <Nichole Petty> <spam_OUTPHXSYSTakeThisOuTspamAOL.COM>
> Aan: .....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU
> Onderwerp: Serial Blues Continued
> Datum: vrijdag 19 juni 1998 1:01
>
[Cut]

> 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?

All instructions that change data with regards to allready existing data
are prone to this effect.  Those instructions have to read, modify and than
write the data back to the origin.  And Yes, BCF does a _Byte_ read, OR the
byte with the appropriate bit-mask (2^Bit-Number) and writes the Byte back.
So does allmost every instruction (exept instructions like CLRxxx, BTFSx,
MOVF, etc.)

But, now the good part, you only have to think about it when using _I/O_.

> Should I  rewrite all my routines to eliminate BSF/BCF instructions?

No. Those you could replace with something like :
 MOVLW 0x01 << BitNumber
 IORWF PORTx
and thus emulating a BSF instruction, but alas, the IORWF has got the same
problem. The only way to get rid of this effect is to use the
'shadow-register' method.  Take a register, modify that and than copy it to
your I/O-Port.
Example :
 BSF SHADOWB,5
 MOVF SHADOWB,W
 MOVWF PORTB

> 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?

Normally, when you define your in & outputs and do not change them anymore
(the directions I mean :-) you won't have a problem.  Only when you change
a Input-pin to Output this will happen.
Example:
 BSF STATUS,RP0
 MOVLW B'00001111'  ; Low 4 are Input, High 4 are Output
 MOVWF TRISB          ;/
 BCF STATUS,RP0
 CLRF PORTB             ; Output the code B'0000xxxx'

; No input is suplied at the low 4 pins. They are all 1 (High)

 BCF PORTB,6            ;Change Output to B'0100xxxx'

This will work fine, until you change one of the Input-pins to Output. Why
?  Ok Follow me...  BCF is a Read-Modify-Write instruction, right ?  Ok.
Read PORTB. Result is ........ Yes, Its 00001111. (try it out !)  Now Set
bit 6 : 01001111. And write it back.  The Output-buffer for the Low 4 pins
has changed from 0000 to 1111 because if the state the inputs were in.  If
you now change pin 0 to Output it will be High, and not Low.

> 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?

My definition of the term is that only BCF and BSF instructions are used
for "bit banging" (changing I/O pin levels), because AND & OR are
Byte-instructions (although they can change a single bit, but so can a INC
or MOV instruction).  But, as said, thats _my_ definition.

> Thanks

Your welcome.

Greetz,
 Rudy Wieser

1998\06\26@055713 by Larry G. Nelson Sr.

flavicon
face
The bit operations work as a read modify write. If you try two consecutive
bit set instructions it is possible that the second one will execute prior
to the first ones effect on its port line can overcome line capacitance. By
using a dummy register to perform these bit manipulations followed by a mov
command to shove the mirrored register to the output port you can avoid the
read modify write problems.

Bit banging usually refers to brute force manipulation of I/O pins to
perform something like serial communication instead of using a part with a
build in USART to perform the operation in hardware while the software is
doing something else. This allows a lower cost part to be used if you have
instruction cycles to burn for "software virtual peripherals".




At 07:01 PM 6/18/98 EDT, you wrote:
>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
>
>
Larry G. Nelson Sr.
L.NelsonspamKILLspamieee.org
http://www.ultranet.com/~nr

More... (looser matching)
- Last day of these posts
- In 1998 , 1999 only
- Today
- New search...