HSPIOUT controlling a ADF4106 PLL

vk3gjm

New Member
Hi All,

I am new to this forum and new to PICAXE and programming Micro-controllers. I have a need to program a Phase Lock Loop ADF4106 register using SPI.

The requirements is a fixed serial string to be sent to the PLL on power up and there will be no change to any register value. The application is a fixed VCO 1st Local oscillator.

I am looking at the 20M device as this has the HSPIOUT command, however I am pushing the proverbial barrow up hill as I have little experience in writing code.

it's time for me to learn and it's the right time. I am looking for several hints and how to use the device to send the following SPI command

F-Register = MSB 010111111000000010010011 LSB = 9F8082 Hex
N-Register = MSB 000000000001100000101001 LSB = C1D Hex
R-Register = MSB 000000000000000000001000 LSB = 8 Hex

Regards

Gerald

VK3GJM
 

hippy

Ex-Staff (retired)
Welcome to the PICAXE Forum.

It always helps to give a link to an appropriate datasheet; saves everyone looking for one and ensures that what they find is the same as what you have. I'd guess -

http://www.analog.com/static/imported-files/data_sheets/ADF4106.pdf

Clocking the data out seems easy enough, 24 bits can be sent as three sets of 8 bits, but on a quick read I couldn't see how one specifies to which register the 24 bits are being clocked to.
 

Goeytex

Senior Member
The registers are selected by control bits 0 and 1. Datasheet P 11 Table 5

The attached code may give you a good start .... Untested of course

Code:
#picaxe 20m2

hspisetup spimode00,spislow


symbol LE = c.0
symbol CE = c.1

InitADF:
high LE
low CE  [COLOR="#008000"] 'Power down ADF 
pause 100

[/COLOR]
[COLOR="#008000"]'====  F-Register =========[/COLOR]
low LE   
hspiout  (%01011111,%10000000,%100100[COLOR="#FF0000"]11[/COLOR]) [COLOR="#008000"] '24bits [/COLOR]
high LE

[COLOR="#008000"]'===== N-Register ========[/COLOR]
low LE
hspiout  (%00000000,%00011000,%001010[COLOR="#FF0000"]01[/COLOR])  [COLOR="#008000"]'24 bits[/COLOR]
high LE

[COLOR="#008000"]'====== R-Register ========[/COLOR]
Low LE
hspiout  (%00000000,%00000000,%000010[COLOR="#FF0000"]00[/COLOR])  [COLOR="#008000"]'24bits[/COLOR]
high LE

High CE    [COLOR="#008000"]'Turn on ADF 
[/COLOR]
MAIN:

[COLOR="#008000"]' Main Programs Starts here[/COLOR]
Also check your calculations:

F-Register = MSB 010111111000000010010011 LSB = 9F8082 Hex
(Should be 0x5F8093)

N-Register = MSB 000000000001100000101001 LSB = C1D Hex
Should be 0x1829
 
Last edited:

vk3gjm

New Member
Hi Hippy and Goeytex,

Data sheet link taken on board, thanks.

OK on clocking data. Tried a couple of things 2 nights ago, however my coding experience goes about as blinking an LED at this stage.

The response from Goeytex makes it much clearer in relation to syntax and flow, thanks. I will give that a go, a good baseline to work from. OK on calcs, not sure where I went wrong.

Again Thank you very much.

Regards

Gerald

VK3GJM
 

vk3gjm

New Member
Hi all,

The 20m2 does not support hspisetup. Scrambled around and found the 20x2. Tried every combination I could think of over 8 hours, still no closer. It shows how bad I am at understanding and writing code. Always time to learn though!

However, I do see data, clock and LE activity from the correct pins on my DSO, therefore the code provided does do the job in terms of sending SPI data.

Just need to work at the ADF4106 register data to ensure it is correct.

Is there any other way or code suggestion?

Regards

Gerald
 
Top