Go Down

### Topic: 4 bit SPI (Read 1 time)previous topic - next topic

#### imtippmann

##### Jan 11, 2013, 09:54 pm
Im VERY new to actually communicating between things so Im not sure what the technical term would be for what I am attempting to do, but i will describe it as best i can.

I am attempting to control a PLL chip (mc145192) that is installed in an old VHF radio.  I want it to sweep from end to end of the band. 136Mhz-174Mhz.

i have read and mapped the SPI data string for a number of channels.  The channels are sent in 24 bits broken into 4 bit hex values.

712730 = 136mhz.
712734 = 136.025
712738 = 136.050
71273c = 136.075

The last digit counts by 4 (0,4,8,c) then resets to 0 counting the next digit up one (0,1,2,3) then counting the next one(0-f) then the next (0-f)

So when after 136.075 (71273c) the master would send the following binary sequence(011100010010011100111100) as read on an osciliscope.

I have written a code that simply counts each digit and outputs digit 1-6 separately, but when i attempt to send the data using the SPI library,  each digit is sent in 8 bits instead of 4, 7 = (00000111), 2 = (00000010).

All that said, how would i get an output of 4 bits instead of 8, or is it simply not possible.

Thank you in advance, I know its a lot easier to help someone that knows more of what they are doing and im probably explaining things backwards.

Casey

#### SurferTim

#1
##### Jan 11, 2013, 10:06 pm
That should be fairly easy. It is only 4 bits to the PLL internally. It can be sent as 3 8-bit values. You can use a shift left 4 bits to move the high nibble into place in each byte. I would use something like this.
Code: [Select]
`// 3 is the HIGH nibblebyte firstByte = 3;// shift into placefirstByte = firstByte << 4;// OR with the LOW nibblefirstByte = firstByte | 5;// do the same for the rest of the three bytes, thendigitalWrite(SS,LOW);delayMicroseconds(1);// send the first two nibblesSPI.transfer(firstByte);// send the second two nibblesSPI.transfer(secondByte);// send the third two nibblesSPI.transfer(thirdByte);// donedigitalWrite(SS,HIGH);`

#### CrossRoads

#2
##### Jan 11, 2013, 10:25 pm
SPI hardware clocks out 8 bits with every SPI.transfer( )

If the remapping of the bits does not work out, you could do your own "software SPI" to switch between sending out 8 bits and 6 bits.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

#### Papa G

#3
##### Jan 12, 2013, 10:24 pm
I recommend you read the data sheet for the part. It gives you the SPI protocol to talk to the part and mentions nothing about having to send it nibbles.

#### nickgammon

#4
##### Jan 13, 2013, 03:55 am
As the others said, to send 0x712730 all you have to do is send 0x71 then 0x27 then 0x30.

You don't need to consider them as 4 bits at all.
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

#### imtippmann

#5
##### Jan 13, 2013, 04:34 am
As I have said before,  Im still excessively new to a lot of this.  I can usually figure things out on my own pretty easily, but sometimes its just easier to just ask the dumb question.  So, Thank you for helping me.

#### nickgammon

#6
##### Jan 13, 2013, 05:07 am
That's OK, the question wasn't dumb.
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

Go Up