4 bit SPI

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.


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.

// 3 is the HIGH nibble
byte firstByte = 3;
// shift into place
firstByte = firstByte << 4;
// OR with the LOW nibble
firstByte = firstByte | 5;
// do the same for the rest of the three bytes, then
// send the first two nibbles
// send the second two nibbles
// send the third two nibbles
// done

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.

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.

MC145192DT.pdf (349 KB)

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.

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.

That's OK, the question wasn't dumb. :slight_smile: