joe rocci - 2017-11-04

Harley,
Working from my tablet (which is tedious), I was able to cut/paste this section of code that sends the 40 bits of data to the AD9850. It's written as a 'bit bang' SPI equivalent in PicBasicPro, but you should get the idea and easily translate it to GCB. You'll have to create a 5 byte freq_byte () array (40 bits) with the binary frequency in the 1st 4 bytes and the control byte in the 5th byte. You'll also have to define port bits for spi_data, spi_clk and spi_latch.

'***********
'   SUBROUTINES
'***********

'Update the DDS frequency

For i = 0 To 3
    freq_byte = freq(i) 'Send the 4 frequency bytes
    Gosub send_spi
Next i
freq_byte = $00 'Send the control byte
Gosub send_spi
spi_latch_dds = 1 'Toggle the DDS Latch line after all 5 bytes
spi_latch_dds = 0 'have been sent.
Return
'***********
' Clocks a single byte out the SPI port
' This 'brute force' single-byte SPI transmit routine is 3-4 times faster than
' SHIFTOUT and it actually compiles to fewer bytes of object code

send_spi:
spi_data = freq_byte.0 'Iterate through all 8 bits of the byte;
spi_clk = 1 'set the SPI_DATA line to the state of that
spi_clk = 0 'bit, and toggle the SPI_CLK line.
spi_data = freq_byte.1
spi_clk = 1
spi_clk = 0
spi_data = freq_byte.2
spi_clk = 1
spi_clk = 0
spi_data = freq_byte.3
spi_clk = 1
spi_clk = 0
spi_data = freq_byte.4
spi_clk = 1
spi_clk = 0
spi_data = freq_byte.5
spi_clk = 1
spi_clk = 0
spi_data = freq_byte.6
spi_clk = 1
spi_clk = 0
spi_data = freq_byte.7
spi_clk = 1
spi_clk = 0
Return
'************

-------- Original message --------
From: Harley Burton haburton@users.sf.net
Date: 11/04/2017 5:13 PM (GMT-05:00)
To: "[gcbasic:discussion]" 579125@discussion.gcbasic.p.re.sf.net
Subject: [gcbasic:discussion] I2C controlling AD9850 DDS

Mike,

Thanks. I guess since it only had the one clock and data lines, I assumed it was an I2C interface...duh. I should have read it more thoroughly and it has been a real challenge to me to make it all come together. I didn one as a parallel interface many years ago but it has been a long time. The PIC16F690 has a synchronous serial port and it looks like that is exactly what I am looking for. You really cleared it up to me.

This site looks to be very good and I am looking forward to working with all of you. When I get a load routine working, I'll be sure and post it for others.

Thanks again,

Harley

N5BFB

73's

I2C controlling AD9850 DDS

Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/gcbasic/discussion/579125/
To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/