![]() |
![]() |
![]() |
|
|
|||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) |
|
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? |
|
|
|
|
|
|
(permalink) |
|
I can't see any reason it wouldn't work.
Mike. |
|
|
|
|
|
|
(permalink) |
|
Seems to work
http://www.open-research.org.uk/ARMuC/SPI.html |
|
|
|
|
|
|
(permalink) |
|
I use 595 with PIC SPI in mode 0,0.
|
|
|
|
|
|
|
(permalink) |
|
How do you do the chip enable? Or just ignore it and use the latch strobe.
|
|
|
|
|
|
|
(permalink) |
|
Of course it can be done
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! |
|
|
|
|
|
|
(permalink) |
|
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 |
|
|
|
|
|
|
(permalink) |
|
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)...
|
|
|
|
|
|
|
(permalink) |
|
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. |
|
|
|
|
|
|
(permalink) |
|
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! |
|
|
|
|
|
|
(permalink) | |
|
Quote:
__________________
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 |
||
|
|
|
|
|
(permalink) |
|
Well I do want the 74HCT595 to work as a 8 bit SPI output expander. Can't see why it wouldn't work.
|
|
|
|
|
|
|
(permalink) |
|
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! |
|
|
|
|
|
|
(permalink) | |
|
Quote:
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 |
||
|
|
|
|
|
(permalink) |
|
I've even used the shift out as a SPI BUS indicator
http://www.blueroomelectronics.com/images/Ladybug90.png |
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| 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 |