Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Thread Tools Display Modes
Old 11th February 2008, 11:38 AM   (permalink)
Default Load shift-registers via SPI?

Has anyone used the PIC MSSP module "SPI" mode to load 8 bit shift registers like the 74HC595?

I've always bit banged this process but if I'm reading the data sheet correctly it seems I could eliminate some software 'overhead' by simply stuffing my 8 bits of data into SSPBUF. Is that correct?
Mike, K8LH is offline   Reply With Quote
Old 11th February 2008, 12:55 PM   (permalink)
Default

I can't see any reason it wouldn't work.

Mike.
Pommie is offline   Reply With Quote
Old 11th February 2008, 05:09 PM   (permalink)
Default

Seems to work
http://www.open-research.org.uk/ARMuC/SPI.html
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is offline   Reply With Quote
Old 11th February 2008, 05:15 PM   (permalink)
Default

I use 595 with PIC SPI in mode 0,0.
felis is offline   Reply With Quote
Old 12th February 2008, 02:12 AM   (permalink)
Default

How do you do the chip enable? Or just ignore it and use the latch strobe.
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is offline   Reply With Quote
Old 12th February 2008, 05:07 AM   (permalink)
Default

Of course it can be done I have always had to latch the strobe manually though. The SPI module just saves time, as it can run full whack. Its handy especially for large LED displays and I/O cards. - Or for getting more out of a 12f675.

I believe the 595 has a 'clock enable' (could be wrong here) which can be used with the CS line. On falling, it enables the SR to clock in data, and when rising, strobe it into its output buffer. SPI was meant for it. One caveat may be you must read the SPI buffer before sending, as it is a data exchange protocol, and expects to load in data as it sends data out, whether it means anything or not.

Blueteeth
__________________
Inconsistency is the key to flexibility!
Blueteeth is offline   Reply With Quote
Old 12th February 2008, 05:22 AM   (permalink)
Default

Hmm I wanted to set the clock and data in on the 595 to be constantly running (since it won't affect the outputs till a latch enable strobe)
The PICs SPI shouldn't care if it doesn't see data on the DI input. Just throw it away in theory.
Hooking it up something like this.
http://www.blueroomelectronics.com/Ladybug8Relay.pdf
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is offline   Reply With Quote
Old 12th February 2008, 11:30 AM   (permalink)
Default

So how many pins are tied up if I use the SPI? Is it four pins? If so, that may be why I decided to bit-bang it (a few years ago)...
Mike, K8LH is offline   Reply With Quote
Old 12th February 2008, 01:46 PM   (permalink)
Default

It's only 3 pins and has no need of the serial input on the SPI hardware port so I just bit-banged it. Same goes for a Microchip digital pot I use - it too is output-only SPI.

Besides, I needed the async serial port and that shares pins with the SPI port. Which is why one could really grow to love the 24 series and their progamable pin assignment :-)

P.
aussiepoof is offline   Reply With Quote
Old 12th February 2008, 09:58 PM   (permalink)
Default

Well, don't want to over complicate things but you could use the USART on a PIC in 'sync mode' with a shift register, may require the clock to be inverted as I dont think it has a polarity setting...so thats in hardware. The shiftregister, as Bill pointed out, has a buffer register, so you can send it what you like..it will only move data from the shiftregister to the output buffer on a low-high strobe transistion.

I have done the above to use those two pins for UART and SPI (with an extra I/O to strobe, and another to select between the two).

As I said, overly complicated in hardware, but it can be done with simple logic/transistors. You just can't use both SPI and USART at the same time obviously...but with the speed of the SPI you won't need to.

Blueteeth
__________________
Inconsistency is the key to flexibility!
Blueteeth is offline   Reply With Quote
Old 13th February 2008, 02:27 AM   (permalink)
Default

Quote:
Originally Posted by Blueteeth
Of course it can be done I have always had to latch the strobe manually though. The SPI module just saves time, as it can run full whack. Its handy especially for large LED displays and I/O cards. - Or for getting more out of a 12f675.
the 12f675 has a hardware spi module? i've been looking for an 8 or 14 pin pic with a slave i2c module, so far, I don't think one exists.
__________________
If you don't have a planet, what good are gold bars?

want to contact me directly? gmail gordonthree
check out my project website: http://projects.dimension-x.net
Favorite numbers:
09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
justDIY is offline   Reply With Quote
Old 13th February 2008, 02:54 AM   (permalink)
Default

Well I do want the 74HCT595 to work as a 8 bit SPI output expander. Can't see why it wouldn't work.
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is offline   Reply With Quote
Old 13th February 2008, 10:05 PM   (permalink)
Default

Just DIY,

Apologies, it looked like I was saying the 12F675 has a HW SPI module..it doesn't (if only it did!). I mentioned it as an example of a shiftregister used for I/O expansion (595 as output, and 165 as input). I know there are some 'newish' PIC's, 14 pin, run down to 2v, internal oscs..that have great peripherals, but I have to see some with an SSP. Looks like you'll have to have a software I2C slave (mikroC has a recently updated and debugged library for it). Software SPI on the other hand is much easier.

Bill, it does work. Although..many just use the clock and data lines, with the strobe/latch being 'manual'. But with multiple SPI devies, one would use mutiple I/O's for seperate CS lines anyway.

Blueteeth.

ps. Didn't want to sound like a know it all, its just personal experience. I've got a couple of LCD's with 595's attached so I can control them serially (SPI), fewer I/O's and the code is very similar...just move to SSPBUFF, instead of PORTB.
__________________
Inconsistency is the key to flexibility!
Blueteeth is offline   Reply With Quote
Old 14th February 2008, 12:45 AM   (permalink)
Default

Quote:
Originally Posted by Blueteeth
Just DIY,

Apologies, it looked like I was saying the 12F675 has a HW SPI module..it doesn't (if only it did!). I mentioned it as an example of a shiftregister used for I/O expansion (595 as output, and 165 as input).
gotcha.

I love the 595 as an output expander myself ... inexpensive, easy to use and the engineers even considered ease of pc board layout when they put almost all the outputs on one side of the chip, instead of scattered all around like the 8 bit ports on a mid sized pic
__________________
If you don't have a planet, what good are gold bars?

want to contact me directly? gmail gordonthree
check out my project website: http://projects.dimension-x.net
Favorite numbers:
09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
justDIY is offline   Reply With Quote
Old 14th February 2008, 02:00 AM   (permalink)
Default

I've even used the shift out as a SPI BUS indicator
http://www.blueroomelectronics.com/images/Ladybug90.png
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Latest
16 bit serial in parallel out shift registers forder Electronic Projects Design/Ideas/Reviews 13 27th October 2007 11:24 AM
64bit shift register with parallel load yugatharan Electronic Projects Design/Ideas/Reviews 5 14th May 2007 05:55 PM
Inchworm adapter bd lemonyx Micro Controllers 9 9th May 2007 07:01 AM
Help loading shift registers... jrz126 Micro Controllers 0 14th November 2005 12:12 PM
shift registers jrz126 Electronic Projects Design/Ideas/Reviews 8 25th September 2004 01:35 AM



All times are GMT. The time now is 01:34 AM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.