28X2 - hspiout - need to get a single clock pulse.

ferrymanr

Member
My external device defaults to parallel mode and requires a sequence of pulses to initialise serial mode. To get the sequence I need to send a single pulse on the hspi clock line (C.3). I can't use the hspiout command as it works in byte mode that will send 8 pulses. Is there any problem with doing a 'pulse C.3' after that pin has been allocated by hspisetup as hspi sck?
Thanks
Dick
 

Goeytex

Senior Member
Is there any problem with doing a 'pulse C.3' after that pin has been allocated by hspisetup as hspi sck?
Yes there is. It won't work because pulseout will have no effect upon the SPI SCK pin c.3 after the hspisetup command is issued.

However you could possibly send the pulse sequence before issuing the HSPISETUP command.
 
Last edited:

westaust55

Moderator
Some additional information such as a link to the datasheet for the device you are trying to communicate with could assist others in resolving your problem.

Confused by the fact that at one point you state:
requires a sequence of pulses to initialise serial mode.
then you say:
To get the sequence I need to send a single pulse on the hspi clock line (C.3).
It is unclear how one pulses makes the sequence of pulses your device needs.
 

ferrymanr

Member
I am driving an AD9851 DDS frequency synthesiser chip. There are four lines required for serial data transfer. These control lines are FQ_UD (pin 8) which transfers data from the buffer to the main register, W_CLK (pin 7), serial data D7 (pin 25) and Master Reset (pin 22).

Note that step 3 below is where a single pulse is required on the clock line, thereafter the transfer is normal SPI so hspisetup could occur after step 3. The only problem that may occur is if an error recovery routine then needs to go through a hardreset and restart at step 2 as hspisetup would then have been run so would have to do an 'hspisetup off' command first.



For serial mode, hard code pins 2, 3, and 4 per figure 18 in the AD8951 data sheet. The seuence to initialise is as follows:-

1) Apply power and REF CLK source to pin 9.

2) Send a master reset pulse. (this places the device in default state and the part is in parallel mode)

3) Send one W_CLK pulse, then send one FQ_UD (this places the device in serial mode)

4) Using W-CLK and D7 load 40 zeros first and then send one FQ_UD. (D7 is the serial data pin). This clears rubbish from the registers.

5) Now using W_CLK and D7 load the next forty bits (five bytes) with your desired FTW (frequency control word) setting and then send one FQ_UD. The correct frequency should be at the output.

Hope this gives an idea of what I'm doing. The actual prpoject is to use a cheap (£7 on eBay) AD9851 board as a signal generator for 1Hz to 70MHz in 1Hz steps with sine and square wave outputs..

Dick
 

westaust55

Moderator
I assume that you are using the hard wired technique to enter the first data byte (%xxxxx110) in parallel mode for the transfer to serial mode prior to your step 3.

For others, the AD9851 datasheet can be found here: http://www.analog.com/static/imported-files/data_sheets/AD9851.pdf

The only problem that may occur is if an error recovery routine then needs to go through a hard reset and restart at step 2 as hspisetup would then have been run so would have to do an 'hspisetup off' command first.
There is the RESET command in PICAXE BASIC which you could use after an AD9851 Master Reset to reset the PICAXE so the program restarts as if power had be cycled.
 
Top