Pages: [1]   Go Down
Author Topic: 4 bit SPI  (Read 619 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset 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
Offline Offline
Faraday Member
**
Karma: 115
Posts: 5360
View Profile
 Bigger Bigger  Smaller Smaller  Reset 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 Offline
Brattain Member
*****
Karma: 436
Posts: 23623
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset 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.
Arduino for Teens available at Amazon.com.

Dallas, TX
Offline Offline
Sr. Member
****
Karma: 10
Posts: 318
View Profile
 Bigger Bigger  Smaller Smaller  Reset 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.

* MC145192DT.pdf (348.76 KB - downloaded 18 times.)
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset 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 Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset 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
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: