Searching \ for ' [PIC] Shift Register Useage-TPIC6A595' 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/microchip/devices.htm?key=pic
Search entire site for: 'Shift Register Useage-TPIC6A595'.

No exact or substring matches. trying for part
PICList Thread
'[PICLIST] [PIC] Shift Register Useage-TPIC6A595'
2002\05\16@133509 by Rex Byrns

flavicon
face
I am going  to order a couple of these and would like to get started coding
on it.  The Pinout that I got from TI looks different that those listed by
Mircea below, and I am trying to get some things clear.

(T/F)
1.I must use 3 IO to control the shift register. (data, srclr, clock)
2.  Any time I adjust a bit, I must set/reset them all (shifting).
3. To code for this puppy, I will need a delay, clock routine of 5khz
       a clock line low (for not yet determined amount of time)
       a data send routine
       a clock high (for a not yet determined amount of time)
4. I only have to clock when updating register
5. If I used 2 shift registers, I could use the same line for clock on both
       since clock by itself won't affect register.

Am I close to right so far?

I realize that using a different PIC would save trouble, but if I wasn't
half doing this
for educational reasons, I would take up basket weaving or something. ;-)

Anyone have any code to share on this subject using a 16f84a or compat?
Preferably at 20mghz (no small counters)?
--- just thought I would ask.

Thanks

Mircea wrote on another topic: (Thanks Mircea)

{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
spam_OUTpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu


2002\05\16@144124 by Bob Ammerman

picon face
----- Original Message -----
From: "Rex Byrns" <.....rexbKILLspamspam@spam@TESTENGEER.COM>
To: <PICLISTspamKILLspamMITVMA.MIT.EDU>
Sent: Thursday, May 16, 2002 1:35 PM
Subject: [PIC] Shift Register Useage-TPIC6A595


> I am going  to order a couple of these and would like to get started
coding
> on it.  The Pinout that I got from TI looks different that those listed by
> Mircea below, and I am trying to get some things clear.
>
> (T/F)
> 1.I must use 3 IO to control the shift register. (data, srclr, clock)

False. You need 3 IO ( SERIN, RCK, SRCK )

> 2.  Any time I adjust a bit, I must set/reset them all (shifting).

Yes.

> 3. To code for this puppy, I will need a delay, clock routine of 5khz
>         a clock line low (for not yet determined amount of time)
>         a data send routine
>         a clock high (for a not yet determined amount of time)

Logic should look something like this:

-- first: load the shift register

for each of 8 output bits:
   output data bit to SERIN pin of chip.
   raise SRCK
   lower SRCK
end for.

-- now copy the shift register to the output register
raise RCK
lower RCK

The 5khz number is ridiculously slow for loading the shift register, but I
didn't notice the timing parameters on the TI datasheet. I would guess a few
no-ops (1 microsecond) between successive I/O operations will be more than
enough.

> 4. I only have to clock when updating register

True

> 5. If I used 2 shift registers, I could use the same line for clock on
both
>         since clock by itself won't affect register.

Probably true, but not fo rthe reason you state. Typically, to use two shift
registers you connect SEROUT from the first one to SERIN of the second. You
connect RCK of both tother and SRCK of both together. You then shift in 16
bits using SRCK before clocking them all to the output with RCK.

> Am I close to right so far?

In the right ballpark.

Bob Ammerman
RAm Systems

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam.....mitvma.mit.edu


2002\05\16@152748 by Bob Blick

face picon face
Try this, it is set to drive two '595 registers in series, and follow Bob
A's other instructions.

You can expand or shrink it as you desire.

I did not need any delays at 4 MHz, you might need a nop here or there at
20MHz

Cheers,

Bob Blick

; SRDATA on PORTB,7
; SRCLOCK on PORTB,6
; SROUT on PORTB,5
; data to send in srlo,srhi
; uses temporary register "count"
; does not trash srlo or srhi

       movlw   0x11    ; 17 decimal
       movwf   count
       goto    ROTATE
LOOP:
       bsf     6,6     ; toggle clock
       bcf     6,6
ROTATE:
       rrf     srhi    ; rotate right
       rrf     srlo    ; rotate into carry
       btfsc   3,0     ; test carry
       bsf     6,7     ; set pin if carry
       btfss   3,0     ; test carry
       bcf     6,7     ; clear pin if not carry
       decfsz  count
       goto    LOOP
       bsf     6,5     ; toggle output register
       bcf     6,5
       return

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspam_OUTspamTakeThisOuTmitvma.mit.edu


2002\05\16@165515 by Rex Byrns

flavicon
face
Thanks.

I am a little confused by the numbers on the left side of the commas.
I am new to pics and the only communication routines I have ever messed with
was 1-wire and SMBus,
and even then I was using vb and C and made it much more complicated than it
had to be and used the parralel
exclusively.

I think that debugging this will make me wish I had in circuit serial
programming capabilities.

{Original Message removed}

2002\05\16@173857 by Bob Blick

face picon face
> I am a little confused by the numbers on the left side of the commas.

Do you mean like this:
       btfss   3,0

The number on the left is the register, the number on the right is the
bit. So this means "bit test F skip on set register 3 bit 0" Register 3 is
the STATUS register, bit 0 of it is the CARRY flag. I could also have
written it as "btfss STATUS,0" or even "SKPC".

I mostly program in C so when I write pic assembler I tend not to use
special mnemonics like skpc but I should have listed it as
btfss STATUS 3,0

Also, PORTB is the same as 6 so something like
bsf     6,7         ; sets portb pin 7 just like
bsf     PORTB,7     ; would do the same thing.

If you look at the map of registers for the PIC you are using you will see
all the locations. The include file you always include at the top of each
program has all those mappings in it.

Cheers,

Bob

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamspam_OUTmitvma.mit.edu


2002\05\16@174434 by Andrew Warren

flavicon
face
Rex Byrns <@spam@PICLISTKILLspamspammitvma.mit.edu> wrote:

> I am a little confused by the numbers on the left side of the commas.
> ....
>
>         btfsc   3,0     ; test carry
>         bsf     6,7     ; set pin if carry
>         btfss   3,0     ; test carry
>         bcf     6,7     ; clear pin if not carry

Rex:

If you look at the Instruction Set section of your PIC's datasheet,
you'll see that bit-oriented instructions (like BSF and BTFSC) take
two operands separated by a comma.  The first operand is a register
number; the second is a bit number.

"BTFSC 3,0", therefore, is testing bit 0 of register 3.  If you look
at the Registers section of your datasheet, you'll see that register
3 is the STATUS register, and that bit 0 of that register is the
Carry Flag.  "BSF 6,7" sets bit 7 of PORTB.

Bob Blick's comments state that RB7 is SRDATA, so the 4-line fragment
I quoted has the effect of copying the state of the carry flag to the
SRDATA pin.

-Andy

=== Andrew Warren -- KILLspamaiwKILLspamspamcypress.com
=== Principal Design Engineer
=== Cypress Semiconductor Corporation
===
=== Opinions expressed above do not
=== necessarily represent those of
=== Cypress Semiconductor Corporation

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu


2002\05\16@180335 by Rex Byrns

flavicon
face
Ok, I got it. So INTCON,0 and B,0 would be the same.  I prefer using the bit
number on the right because
I have nice little tables made for quick ref on both system registers and
the ones I create.
Never thought to try it on the left.

Does for example        bsf PORTB,RB3
                       bsf PORTB,RB4
                       bsf PORTB,RB2

use more memory than
                       movlw B'00011100'
                       movwf PORTB
?

While we are on the subject, I would really like to know how I get rid of
All upper case variables or all Lower case variables when I go to watch
window. One or the other.
I see that the inc file uses all upper, so I changed all w to W, portb to
PORTB etc, but they are still there.
I copied my asm file to a new project and still get both.  Then confusing
part is that it is the w that works in the
watch window and not the W.

I guess I am being picky.  I am used to programming environments enforcing
case, and I guess it is in part.
Just not the part I want.

OK I am being a sponge, asking more questions than a three year old...

Thanks

{Original Message removed}

2002\05\16@181828 by Andrew Warren

flavicon
face
Rex Byrns <spamBeGonePICLISTspamBeGonespammitvma.mit.edu> wrote:

> Does for example        bsf PORTB,RB3
>                         bsf PORTB,RB4
>                         bsf PORTB,RB2
>
> use more memory than
>                         movlw B'00011100'
>                         movwf PORTB

   Yes.  On your PIC (you can verify this by reading the datasheet),
   each instruction consumes one word of memory.  Three BSFs takes
   three words of memory and a MOVLW/MOVWF pair takes only two.

   The MOVLW/MOVWF will force bits 0, 1, 5, 6, and 7 of PORTB to 0
   (which you may or may not be a good thing in your application),
   and it will also sidestep any read/modify/write issues that
   might prevent bits 3 and/or 4 from being set to 1 (which is a
   good thing in nearly all applications).

   It also runs faster (2 instruction cycles versus 3).

   -Andy

=== Andrew Warren -- TakeThisOuTaiwEraseMEspamspam_OUTcypress.com
=== Principal Design Engineer
=== Cypress Semiconductor Corporation
===
=== Opinions expressed above do not
=== necessarily represent those of
=== Cypress Semiconductor Corporation

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestspamTakeThisOuTmitvma.mit.edu


2002\05\16@185203 by Michael Johnston

flavicon
face
Bob
Could i use this code for a max7219 ic to display time?
My clock uses this chip to display time like a regular clock
Thanks
Mike Johnston
{Original Message removed}

2002\05\16@190748 by Bob Blick

face picon face
On Thu, 16 May 2002, Michael Johnston wrote:

> Bob
> Could i use this code for a max7219 ic to display time?
> My clock uses this chip to display time like a regular clock

I haven't used the max7219 in a long time, so I forget the polarity of the
clk and load. If it's different you can change bcf for bsf on the toggles.
But the basic idea is the same, just put in as many "rrf"  lines and add
variables as you need and make the count initialise bigger to fit(it needs
to be 1 more than the number of bits shifted out).

Cheers,

Bob

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestEraseMEspam.....mitvma.mit.edu


2002\05\16@194030 by Michael Johnston

flavicon
face
Bob
thanks for the idea. Ive been toying with this for two days. I was trying to
figure out how to send the clocking sequence to the 7219.  I was trying to
figure out if i have to make 8 data tables for each element  to flash the
time or some other ide
thanks again
Mike Johnston
{Original Message removed}

2002\05\16@231240 by Byron A Jeff

face picon face
On Thu, May 16, 2002 at 12:35:56PM -0500, Rex Byrns wrote:

> [ shift register stuff deleted.... ]
> Anyone have any code to share on this subject using a 16f84a or compat?
> Preferably at 20mghz (no small counters)?

I just breifly wanted to talk about compatible. The 16F628:

http://www.finitesite.com/d3jsys/16F628.html

BAJ

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspammitvma.mit.edu


2002\05\17@032935 by Mircea Chiriciuc

flavicon
face
> 1.I must use 3 IO to control the shift register. (data, srclr, clock)
#define data PORTA,0
#define srclr PORTA,1
#define clock PORTA,2

I am used to define port pins as variables when it's possible so I dont end
up not knowing which pin is doing what.

> 2.  Any time I adjust a bit, I must set/reset them all (shifting).
- right.

> 3. To code for this puppy, I will need a delay, clock routine of 5khz
>         a clock line low (for not yet determined amount of time)
>         a data send routine
>         a clock high (for a not yet determined amount of time)
; RESET shift registers (since 595 max freq if 20Mhz and
; PICs instrunctions execute at Fosc/4 no need for delays
; and I thing the relays won't sense these speed, but it they
; do you only have to integrate the command signals
; PIC pin - Resistor - Capacitor to ground - transistor base
; to get a hardware delay so the relays will bu munb to the fast changes)
bcf    srclr
nop
nop
bsf    srclr
;send data
movlw    .8                ; you have to send 8 bits
movwf    loopvar        ; variable for controling the loop
loop:
bcf    clock
rrf    outbyte,f               ; put bit to be sent in CARRY
btfss status,c
bcf    data
btfsc status,c
bsf    data
bsf    clock   ; put clock high
nop                ; wait a short while
nop
decfsz loopvar,f   ; if all 8 bites sent then get out you are donne
goto  loop
bcf    clock    ;leave clock low
return

You get away like this without any delay routine, clock routine (5kHz?) this
is the routine I am using in my project and it's tested

> 4. I only have to clock when updating register
- right

> 5. If I used 2 shift registers, I could use the same line for clock on
both
>         since clock by itself won't affect register.
- not quite right. If you are updating both of them in the same routine (you
obtain a 16bit shift register) you have common clock and reset. The
registers have to be cascaded in order to obtain this, but if you want two
independent 8 bit shift registers, you have to have separate clock lines
since the clock "moves" the data at the input to te "next" output. You still
can have common data lines since data without clock does nothing.

This is not "trouble" as you call it. It's experience and cost saving! Stick
on using only what you need and you'l have better and cheaper projects! PICs
with more pins have more functions and that means to you more trouble in
writting the code.

Hope beeing of some help,
Mircea Chiriciuc
EMCO INVEST

P.S. The wiring is the one I used and it seems OK to me.

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\05\17@095713 by Rex Byrns

flavicon
face
Just to let everyone know - using MPLAB 5.60.00 - Device file version
5.00.41

bsf PORTB,RB4
  |
returns on build
  |
Error[113]   C:\PROGRA~1\MPLAB\FEEDER2.ASM 117 : Symbol not previously
defined (RB4)

My P16f84a.inc file contains nothing about any of these bits on the ports.
The file mod date and time are the same as many other files of this type.

I see how I could easily add them in.  The  revision info is:

;Rev:   Date:    Reason:

;1.00   2/15/99 Initial Release

Is there something I am missing?

{Original Message removed}

2002\05\17@104000 by Bob Blick

face picon face
> bsf PORTB,RB4
>    |
> returns on build
>    |
> Error[113]   C:\PROGRA~1\MPLAB\FEEDER2.ASM 117 : Symbol not previously
> defined (RB4)

I would do:
bsf PORTB,4

Cheers,
Bob

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\05\17@104341 by Bob Ammerman

picon face
The bits on PORTA, PORTB etc do _not_ have names in the .INC file.

Just use the syntax  PORTB,3 for pin RB3

Bob Ammerman
RAm Systems

----- Original Message -----
From: "Rex Byrns" <RemoveMErexbEraseMEspamEraseMETESTENGEER.COM>
To: <RemoveMEPICLISTspam_OUTspamKILLspamMITVMA.MIT.EDU>
Sent: Friday, May 17, 2002 9:55 AM
Subject: Re: [PIC] Shift Register Useage-TPIC6A595


{Quote hidden}

> {Original Message removed}

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