Searching \ for 'serial code' 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 code'.

Truncated match.
PICList Thread
'serial code'
1995\02\26@161323 by Henri

flavicon
face
Hi there,
currently there was a discussion about serial programming and not
reinventing the wheel. Well, that's exactly how I feel, but I
didn't catch up any piece of code. So does somebody of you
have a teenie weenie piece of assembler code for reading serial
data on a 2-wire interface (SCLK,DATA) ?

Henri

--
=============> The sanest place is still behind the trigger <===============
[]-------------------------------[]---------------------------------------[]
||         Henri Schultze        || Magdeburg D-39122 Alt-Fermersleben 88 ||
||   spam_OUThenriTakeThisOuTspamfscz-md.boerde.de     ||          The Cracker Company          ||
[]-------------------------------[]---------------------------------------[]
=================> in a world of compromise, some don't <===================

1995\02\26@202126 by Andrew Warren

face
flavicon
face
Henri Schultze (.....henriKILLspamspam@spam@fscz-md.boerde.de) wrote:

>currently there was a discussion about serial programming and not
>reinventing the wheel. Well, that's exactly how I feel, but I
>didn't catch up any piece of code. So does somebody of you
>have a teenie weenie piece of assembler code for reading serial
>data on a 2-wire interface (SCLK,DATA) ?


Come on, Henri... Assembly-language programming doesn't get much easier
than this.

Since you didn't give any details, I'll assume that DATA is valid when
SCLK is high, and that you're only reading 8 bits from the interface.

       #DEFINE DATA    [any port]
       #DEFINE SCLK    [any other port]

       RECEIVE EQU     [any file register]

       ;.... initialize registers, setup port TRIS registers, etc. ....

       GETBYTE MOVLW   00000001B       ;PUT A "1" IN "RECEIVE"'S LSB SO
               MOVWF   RECEIVE         ;WE'LL KNOW WHEN WE'VE RECEIVED
                                       ;8 BITS.

               CLRC                    ;ASSUME WE'LL SHIFT A "0" INTO
                                       ;"RECEIVE".

       GETBIT  BTFSS   SCLK            ;WAIT FOR SCLK TO GO HIGH (CARRY
               GOTO    $-1             ;IS ALWAYS CLEAR HERE).

               BTFSC   DATA            ;IF DATA = 0, SKIP AHEAD.
               SETC                    ;OTHERWISE, SETUP TO SHIFT A
                                       ;"1" INTO "RECEIVE".

               RLF     RECEIVE         ;SHIFT THE CARRY INTO "RECEIVE".

               SKPNC                   ;IF WE'VE RECEIVED ALL 8 BITS,
               GOTO    DONE            ;GO EXIT.

               BTFSC   SCLK            ;OTHERWISE, WAIT FOR SCLK TO GO
               GOTO    $-1             ;LOW.

               GOTO    GETBIT          ;LOOP BACK.

       DONE    ....                    ;8 BITS OF RECEIVED DATA ARE IN
                                       ;"RECEIVE".  FIRST BIT RECEIVED
                                       ;IS IN THE MSB, LAST BIT IS IN
                                       ;THE LSB.

-Andy


--
Andrew Warren - fastfwdspamKILLspamix.netcom.com
Fast Forward Engineering, Vista, California

1995\02\27@155453 by Henri

flavicon
face
-Andy wrote:
>
> Come on, Henri... Assembly-language programming doesn't get much easier
> than this.
Ohh. Shame on me :-)
But I mostly end up with some optimized code from some "AN..." of the
Embedded Control Handbook". So I like to see something good. And two
persons (mostly) have two different ideas. So I could already catch
some good idea from your code. Thanks for that.
>
> Since you didn't give any details, I'll assume that DATA is valid when
> SCLK is high, and that you're only reading 8 bits from the interface.
>
Well, I didn't want bother you all to much. So I reduced the problem
to a small kernel.
Actually I have to interface an ADC AD7714 to a PIC hostcontroller.
Things get a little bit easier when I (e.g. the PIC) provide the
SCLK. BTW: it's also a 3-wire interface, but that doesn't make a
difference in general. I have to send lots of control data to the
ADC, then initiate a read-cycle, then read 16/24bit of data.
Then I'll do just something with that conversion data I hopefully get.
But plenties of time probably will walk throu the land before I get
this far.

Bye
          Henri

--

{Quote hidden}

--
=============> The sanest place is still behind the trigger <===============
[]-------------------------------[]---------------------------------------[]
||         Henri Schultze        || Magdeburg D-39122 Alt-Fermersleben 88 ||
||   .....henriKILLspamspam.....fscz-md.boerde.de     ||          The Cracker Company          ||
[]-------------------------------[]---------------------------------------[]
=================> in a world of compromise, some don't <===================

1995\02\27@231956 by Andrew Warren

face
flavicon
face
Henri Schultze (EraseMEhenrispam_OUTspamTakeThisOuTfscz-md.boerde.de) quoted me...

>> Come on, Henri... Assembly-language programming doesn't get much
>> easier than this.

..then wrote:

>Ohh. Shame on me :-)


       Henri:

       Sorry... I didn't mean for it to sound like that.

       -Andy


--
Andrew Warren - fastfwdspamspam_OUTix.netcom.com
Fast Forward Engineering, Vista, California

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