shiftOut Method?

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
mhepp
Posts: 19
Joined: Thu May 28, 2015 5:50 pm

shiftOut Method?

Post by mhepp » Wed Jul 12, 2017 2:52 pm

Dear all:

I am trying to control a AD9851 DDS [1] with a MicroPython board. Now, is there a function for sending byte data via a data and clock pin, same as the following Arduino function:

https://www.arduino.cc/en/Reference/ShiftOut

?
Basically, what I need to do is sending a 40 bit value to a chip using a clock and a data line.

On an Arduino, this can be neatly done like so (taken from [2]):

Code: Select all

digitalWrite(LOAD, LOW);
shiftOut(DATA, CLOCK, LSBFIRST, tuning_word);
shiftOut(DATA, CLOCK, LSBFIRST, tuning_word >> 8);
shiftOut(DATA, CLOCK, LSBFIRST, tuning_word >> 16);
shiftOut(DATA, CLOCK, LSBFIRST, tuning_word >> 24);
shiftOut(DATA, CLOCK, LSBFIRST, 0x09);
digitalWrite(LOAD, HIGH);
Before I implement it on my own, I wanted to make sure there no such thing as a built-in.

Thanks for your hints!

Martin

[1] http://www.analog.com/media/en/technica ... AD9851.pdf
[2] http://blog.marxy.org/2008/05/controlli ... 2285642730

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: shiftOut Method?

Post by Roberthh » Wed Jul 12, 2017 3:56 pm

As far as I understand the manual, you can use SPI for that purpose. In addition, you need to connect the FQ_UD line and Reset. After resetting, you'll need to switch the AD9851 to serial mode. Since thar requirfes toggling the Clock line once, you might have to set the clock line first as Pin output for a manual toggle, and then enable its use as SPI Clck.

mhepp
Posts: 19
Joined: Thu May 28, 2015 5:50 pm

Re: shiftOut Method?

Post by mhepp » Wed Jul 12, 2017 4:35 pm

Thanks, Robert! Will try that!
Martin

cefn
Posts: 230
Joined: Tue Aug 09, 2016 10:58 am

Re: shiftOut Method?

Post by cefn » Tue Aug 01, 2017 5:14 pm

This reference code was used for a Jack-in-the-Beanstalk animation as part of our Minilluminations, in case you need a reference version of working (but basic and not performant) ShiftRegister code...

https://github.com/ShrimpingIt/tableaux ... lk/main.py

Post Reply