CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Trouble controlling daisy chained AD5263s

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
jj9921



Joined: 13 Dec 2021
Posts: 3

View user's profile Send private message

Trouble controlling daisy chained AD5263s
PostPosted: Mon Dec 13, 2021 2:45 pm     Reply with quote

I have been trying to control 2 daisy chained AD5263 digipots with a PIC16F1509. I have gotten the value of the first to work but the second is stuck. Here is the code that I currently have.
Code:
#include <16f1509.h>
#fuses HS, NOWDT, NOLVP, PROTECT
#device ICD=TRUE
#device ADC=10
#use delay(clock=16000000, int)
#use rs232(UART1, baud=31250,parity=N,stop=1,bits=8, ERRORS)
#use spi(MASTER, SPI1, FORCE_SW, IDLE=0, SAMPLE_RISE, ENABLE=PIN_C6, BITS=20, STREAM=STREAM1, BAUD=400000)

while(1){

spi_xfer(STREAM1, (0b01111111110100000000), 20);

}

The second 10 bits in the number control the first pot's values fine but there is no change to the value on the second when I change the first set of 10 bits. Is there a setting that I am missing or do I need a separate line to send data to each of the pots?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Dec 13, 2021 7:00 pm     Reply with quote

The AD5263 data sheet says on pg 7:
Quote:

SDO/O1 -
Serial Data Output in SPI Mode. Open-drain transistor requires pull-up resistor.

Do you have a pull-up resistor on the SDO pin of the 1st AD5263 ?
Its needed because SDO is an open drain output.

On page 19 of the AD5263 data sheet, in Figure 47, it recommends
a 2.2K pullup on SDO.
jj9921



Joined: 13 Dec 2021
Posts: 3

View user's profile Send private message

PostPosted: Mon Dec 13, 2021 7:09 pm     Reply with quote

Yeah it has that so it should just be a code issue.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Dec 13, 2021 10:36 pm     Reply with quote

What is your CCS compiler version ? It's a 4-digit number at the
top of your .LST file, such as 5.105.
jj9921



Joined: 13 Dec 2021
Posts: 3

View user's profile Send private message

PostPosted: Mon Dec 13, 2021 11:20 pm     Reply with quote

Its V4.140
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Dec 14, 2021 12:23 am     Reply with quote

The code between 4.140 and 5.105 matched in all the important areas.

Can you post a schematic of your project ?

You have to upload it to a free web hosting site like imgur.com
and them post a link to it here.
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Tue Dec 14, 2021 4:19 am     Reply with quote

Key thing:

Quote:

), 20);


You cannot do this. The _hardware_ SPI only clocks in multiples of 8bits.

The ADS5263, does have in an application note for use with devices that
do this the note, that it is the _last_ ten bits that are used by the device.
This is also noted in the data sheet:
Quote:

Note that only the last 10 bits that are clocked into the register are latched into the decoder.

You need to change this to clock 24bits. Send your 20 bits as the last 20
bits of the 24bit transfer. Since SPI sends MSb first, should be exactly the
same as your current data
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Dec 14, 2021 8:23 am     Reply with quote

But he has FORCE_SW in his #use spi() statement.
temtronic



Joined: 01 Jul 2010
Posts: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Dec 15, 2021 8:31 pm     Reply with quote

OK, perhaps a silly question but...
Have you got BOTH digipots to work, independently ??
Any chance there's a wiring issue (spi out of #1 going to SPI out of #2 ??)?
Missing SPI#2 clock ?
You need to confirm the hardware works 100% THEN look at the code.
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Wed Dec 15, 2021 11:48 pm     Reply with quote

PCM programmer wrote:
But he has FORCE_SW in his #use spi() statement.


Yes, but he is not specifying SPI pins, instead saying SPI1. I don't know
if the old compiler would handle this correctly. Suspect it might force
hardware (using SPIx is always equivalent to FORCE_HW).
I didn't keep and V5 compilers this early, so can't test.
Honestly better to use 24bits which then avoids the issue.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Dec 16, 2021 2:34 am     Reply with quote

I installed vs. 4.140 and looked at the ASM code. It uses the SPI1
pins to do software SPI. I said above:
Quote:
The code between 4.140 and 5.105 matched in all the important areas.

I think he has a hardware problem. Possibly something simple such
as incorrect connections from the first AD5263 to the 2nd one.
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Thu Dec 16, 2021 2:48 am     Reply with quote

OK. Fair enough. I must admit I tend to not trust older versions to handle
such a complex 'translation' of the user's desires!...
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Thu Dec 16, 2021 4:15 am     Reply with quote

Look at what he sends:

0b01111111110100000000

This has both the ADC's on the same address... 01

Wrong. Sad

There is another problem. Multi byte transfers on SPI, are sent MSB first,
but the bytes are sent LSb first (which is what the chip wants).
He would actually have to re-order the bytes to get the data to send
in the correct order....
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Dec 16, 2021 8:04 am     Reply with quote

The AD5263 is a quad digital pot. The first two bits of each 10-bit
group select which of the four pots to use in each chip. So his code
is OK.

The AD5263 wants the D7 bit clocked in first after the two address bits.
The CCS software SPI library code sends it that way. I don't see a problem.

https://www.analog.com/media/en/technical-documentation/data-sheets/AD5263.pdf

The OP appears to have lost interest. He hasn't responded in a
couple of days.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group