Pages: [1]   Go Down
 Author Topic: 4 bit SPI  (Read 241 times) 0 Members and 1 Guest are viewing this topic.
Offline
Newbie
Karma: 0
Posts: 2
 « on: January 11, 2013, 03:54:53 pm » Bigger Smaller Reset

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

 Logged

Miramar Beach, Florida
Online
Karma: 49
Posts: 3442
 « Reply #1 on: January 11, 2013, 04:06:58 pm » Bigger Smaller Reset

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:
// 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
digitalWrite(SS,LOW);
delayMicroseconds(1);
// send the first two nibbles
SPI.transfer(firstByte);
// send the second two nibbles
SPI.transfer(secondByte);
// send the third two nibbles
SPI.transfer(thirdByte);
// done
digitalWrite(SS,HIGH);
 Logged

Global Moderator
Boston area, metrowest
Offline
Brattain Member
Karma: 240
Posts: 16426
Available for Design & Build services
 « Reply #2 on: January 11, 2013, 04:25:44 pm » Bigger Smaller Reset

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.
 Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17

Dallas, TX
Offline
Sr. Member
Karma: 8
Posts: 314
 « Reply #3 on: January 12, 2013, 04:24:24 pm » Bigger Smaller Reset

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.
 Logged

Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 218
Posts: 13896
Lua rocks!
 « Reply #4 on: January 12, 2013, 09:55:31 pm » Bigger Smaller Reset

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.
 Logged

Offline
Newbie
Karma: 0
Posts: 2
 « Reply #5 on: January 12, 2013, 10:34:04 pm » Bigger Smaller Reset

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.
 Logged

Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 218
Posts: 13896
Lua rocks!
 « Reply #6 on: January 12, 2013, 11:07:03 pm » Bigger Smaller Reset

That's OK, the question wasn't dumb.
 Logged

 Pages: [1]   Go Up