Searching \ for 'Byte serial output through RA0' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/io/serials.htm?key=serial
Search entire site for: 'Byte serial output through RA0'.

Truncated match.
PICList Thread
'Byte serial output through RA0'
1998\10\13@164357 by netquake

flavicon
face
Hi.

OK, here's what I have to do:

Obtain a byte value from a table read and output each bit of it
(from bit 0 to bit 7)(or LSB to MSB) trough porta pin RA0 which
I have previously set as an output. Then fetch another table byte
and do the same, etc.
To achieve this I thought RRF (rotate right f trough carry) instr.
would be perfect.
The thing is I'm wondering what would be the best way to count the loop
(porta register must rotate 8 times for each byte but no more, then
must read the next byte).

Any suggestions?

Thank you very much.

P.D.: Has anybody developed a way to replace an N (result < 0) status flag?

--------------------------------------------
"I must not fear. Fear is the mind-killer.
Fear is the little death that brings total
obliteration. I will face my fear... I will
permit it to pass over me and through me."

Kwisatz Haderach - Dune

       netQ
<spam_OUTnetquakeTakeThisOuTspaminnocent.com>

1998\10\13@193345 by James Cameron

flavicon
face
netQ wrote:
> Obtain a byte value from a table read and output each bit of it
> (from bit 0 to bit 7)(or LSB to MSB) trough porta pin RA0 which
> I have previously set as an output. Then fetch another table byte
> and do the same, etc.

I see a table, and an output pin, a current table offset value, a
current table value, and a bit offset value.  The last you could hold in
the accumulator (W), unless you wanted an interbit delay that happened
to use W.

Normally I'd draw it on paper first ... give it a try if you get stuck,
but now I know enough to just code it up.

Untested brain-dump code follows.


offset  equ     ?               ; current offset
value   equ     ?               ; current value
count   equ     ?               ; bit counter

table   addwf   pcl,f           ; the table of values to send
       retlw   45
       retlw   56
       retlw   67
       retlw   78
       retlw   0

send                            ; send the table of data
       clrf    offset          ; start at top of table

next
       movf    offset          ; fetch the offset
       call    table           ; get the table byte
       movwf   value           ; save it
       movf    value           ; grab it again to set Z flag
       btfsc   status,z
       goto    fall            ; drop out of loop on end of table

       movlw   8               ; number of bits to send
       movwf   count
loop
       rrf     value,f         ; shift out the bit
       btfsc   status,c        ; send it to RA0
       bsf     porta,0
       btfss   status,c
       bcf     porta,0
       decfsz  count           ; decrement and test counter
       goto    loop            ; loop until eight bits sent

       incf    offset          ; look at next table entry
       goto    next

fall
       ...


> P.D.: Has anybody developed a way to replace an N (result < 0) status
> flag?

What?

Test bit 7 of the result!  ;-)

Assuming you are using signed integers.

--
James Cameron                                    (.....cameronKILLspamspam@spam@stl.dec.com)
Digital Equipment Corporation (Australia) Pty. Ltd. A.C.N. 000 446 800

1998\10\13@201835 by Regulus Berdin

flavicon
face
netQ wrote:
> Obtain a byte value from a table read and output each bit of it
> (from bit 0 to bit 7)(or LSB to MSB) trough porta pin RA0 which
> I have previously set as an output. Then fetch another table byte
> and do the same, etc.
>  To achieve this I thought RRF (rotate right f trough carry) instr.
> would be perfect.
>  The thing is I'm wondering what would be the best way to count the loop
> (porta register must rotate 8 times for each byte but no more, then
> must read the next byte).

This can be done without rotate:

table:
       addwf   PCL
       dt      data1 ^ (LOW (data1<<1))
       dt      data2 ^ (LOW (data2<<1))
       dt      data3 ^ (LOW (data3<<1))
       dt      data4 ^ (LOW (data4<<1))
       .
       .
       .

serial_out:
       call    table
       movwf   temp
       xorwf   PORTA,w
       andlw   1
       movlw   1
       skpz
        xorwf  PORTA
       btfsc   temp,1
        xorwf  PORTA
       btfsc   temp,2
        xorwf  PORTA
       btfsc   temp,3
        xorwf  PORTA
       btfsc   temp,4
        xorwf  PORTA
       btfsc   temp,5
        xorwf  PORTA
       btfsc   temp,6
        xorwf  PORTA
       btfsc   temp,7
        xorwf  PORTA
       return

> P.D.: Has anybody developed a way to replace an N (result < 0) status flag?
Invert the Carry flag, you will get "N".

Reggie

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