DSPRelated.com
Forums

DAC with a TMS320F240 via SPI interface

Started by Lotfi April 21, 2004
Hi there,

I have a pb to reach maximum update rate for a serial Quad DAC TLV 5614 with
a TMS320F240 DSP that talks to him through SPI interface.
THe SPI is configured as follow

        LDP     #0E0h
       SPLK  #0087h,SPI_CNTL1    ; Reset SPI by writing 1 to SWRST
       SPLK  #000Ch,SPI_CNTL2   ; Disable ints & TALK, normal clock, master
mode
       SPLK #0000h,SPI_PRI    ; Set SPI interrupt to high priority.
       SPLK #0000h,SPI_BAUD   ; Baudrate = Fatest as possible ! SYSCLK/4
       SPLK #0000h,SPI_STATUS   ; Clear the SPI interrupt status bits
       SPLK #0006h,SPI_CNTL2   ; Enable TALK, No CLK ph, master mode +
disable SPI Int
       SPLK #0052h,SPI_PORT_C1  ; Enable the SPICLK pin function. ; SPISTE
as output pin et mise � 1 ie desactive
       SPLK #0022h,SPI_PORT_C2  ; Set SIMO & SOMI functions to serial I/O
       SPLK  #0007h,SPI_CNTL1    ; Release SWRST, clock polarity 0, 8 bits


it sends correct SCLK=(SPICLK pin), /CS=(IOPA1 pin) and /FS =(SPISTE pin)
signals to the DAC
I wrote a routine that is called every 100 us and that refresh the DAC DATA,
say I am working only with one DAC (A).
each time it will send the data and increment by 1000 the data to be sent
next time.
it sends, 0 (ie 0V), 1000 (1V), 2000 (2V), 3000 (3V), 4000 (4V) then it
comes back to 0.
the pb is that I don't see all the steps but only changes every 200 us and
not every 100 us

my code seems correct because it takes into account but not at the right
rate :-(

every 100 us, these parts of code are called
...
   LACL j
   ADD  #1000
   SACL j
   SUB #1000h
   BCND pasdeRAZj,LT
   splk #0, j
pasdeRAZj
...
...

   LACL  j
   SACL DAC1
...
   LACL DAC1                 ; Load data du DAC 1 into the ACC
   SACL DataDAC
   SPLK #0010h, DAC_OR
...

   CS_DACon    ; Active le DAC
; sort sur DAC numero DAC_OR
   LDP #0E0h
   LACL  SPI_PORT_C1    ; SPISTE � 0 to start the transfer
   AND   #0BFh
   SACL  SPI_PORT_C1

   LDP   #DataDAC
   LACC DataDAC,8       ; Load data du DataDAC into the Hi ACC
   SACH tmp
   LACL tmp
   AND   #000Fh     ; Set the DAC control bits (4-7) ou plutot D12-D15
   OR  DAC_OR    ; DAC voie "DAC_OR", SPD=fast mode
   LDP #0E0h
   SACL  SPI_DAT     ; Transmit HI byte
   LACL SPI_BUF     ; clear le SPI_STATUS,BIT6 : donn�e_envoy�
att1 BIT  SPI_STATUS,BIT6
   BCND att1,NTC
   LACL SPI_BUF     ; clear le SPI_STATUS,BIT6 : donn�e_envoy�

low_byte
   LACL DataDAC      ; Read the current value of
   AND #0FFh      ; data, mask off the lower
   LDP #0E0h
   SACL SPI_DAT     ; Transmit the LOW byte
   LACL SPI_BUF     ; clear le SPI_STATUS,BIT6 : donn�e_envoy�

; transfert fini ?
att2 BIT  SPI_STATUS,BIT6
   BCND att2,NTC
   LACL SPI_BUF     ; clear le SPI_STATUS,BIT6 : donn�e_envoy�

   LACL  SPI_PORT_C1    ; en fait : set SPIPC1.6 � 1 => SPISTE pin � 1 ie
latch the Data !
   OR  #040h
   SACL  SPI_PORT_C1    ; latch the data into the DAC
   CS_DACoff    ; Desactive le DAC


where the macro ares :
----------------------
CS_DACon  .macro
       LDP   #00E1h
       LACC  PADATDIR
       AND  #0FFFDh    ; IOPA1 mise � 0 ie DAC activ�
       SACL  PADATDIR
     .endm
CS_DACoff  .macro
       LDP   #00E1h
       LACC  PADATDIR
       OR  #0002h    ; IOPA1 mise � 1 ie DAC desactiv�
       SACL  PADATDIR
     .endm



I tried to slower the spiclk, to make the 2nd send by spi int, same pb...
the TLV5614 doc say it has a setting time of 3 us ! yes it is true (I
verifed it) but only, if it takes it into account:-)
???

thanks for your kind help



I solved by myself
the pb was with clock polarity (wrong one)
this conf works better :-)


   SPLK  #00C7h,SPI_CNTL1    ; Reset SPI by writing 1 to SWRST !!!clk pol1
   SPLK  #000Ch,SPI_CNTL2   ; Disable ints & TALK, normal clock, master mode
   SPLK #0000h,SPI_PRI    ; Set SPI interrupt to high priority.
   SPLK #0000h,SPI_BAUD   ; Baudrate = Fatest as possible ! SYSCLK/4 et �a
marche !
   SPLK #0000h,SPI_STATUS   ; Clear the SPI interrupt status bits
   SPLK #0006h,SPI_CNTL2   ; Enable TALK, No CLK ph, master mode + disable
SPI Int
   SPLK #0052h,SPI_PORT_C1  ; Enable the SPICLK pin function. ; SPISTE as
output pin et mise � 1 ie desactive
   SPLK #0022h,SPI_PORT_C2  ; Set SIMO & SOMI functions to serial I/O
   SPLK  #0047h,SPI_CNTL1    ; Release SWRST, clock polarity 1, 8 bits



"Lotfi" <llbaghli(nospam)@ifrance.com> a &#4294967295;crit dans le message news:
c65hoh$h3d$1@arcturus.ciril.fr...
> Hi there, > > I have a pb to reach maximum update rate for a serial Quad DAC TLV 5614
with
> a TMS320F240 DSP that talks to him through SPI interface. > THe SPI is configured as follow > > LDP #0E0h > SPLK #0087h,SPI_CNTL1 ; Reset SPI by writing 1 to SWRST > SPLK #000Ch,SPI_CNTL2 ; Disable ints & TALK, normal clock,
master
> mode > SPLK #0000h,SPI_PRI ; Set SPI interrupt to high priority. > SPLK #0000h,SPI_BAUD ; Baudrate = Fatest as possible ! SYSCLK/4 > SPLK #0000h,SPI_STATUS ; Clear the SPI interrupt status bits > SPLK #0006h,SPI_CNTL2 ; Enable TALK, No CLK ph, master mode + > disable SPI Int > SPLK #0052h,SPI_PORT_C1 ; Enable the SPICLK pin function. ; SPISTE > as output pin et mise &#4294967295; 1 ie desactive > SPLK #0022h,SPI_PORT_C2 ; Set SIMO & SOMI functions to serial I/O > SPLK #0007h,SPI_CNTL1 ; Release SWRST, clock polarity 0, 8 bits > > > it sends correct SCLK=(SPICLK pin), /CS=(IOPA1 pin) and /FS =(SPISTE pin) > signals to the DAC > I wrote a routine that is called every 100 us and that refresh the DAC
DATA,
> say I am working only with one DAC (A). > each time it will send the data and increment by 1000 the data to be sent > next time. > it sends, 0 (ie 0V), 1000 (1V), 2000 (2V), 3000 (3V), 4000 (4V) then it > comes back to 0. > the pb is that I don't see all the steps but only changes every 200 us and > not every 100 us > > my code seems correct because it takes into account but not at the right > rate :-( > > every 100 us, these parts of code are called > ... > LACL j > ADD #1000 > SACL j > SUB #1000h > BCND pasdeRAZj,LT > splk #0, j > pasdeRAZj > ... > ... > > LACL j > SACL DAC1 > ... > LACL DAC1 ; Load data du DAC 1 into the ACC > SACL DataDAC > SPLK #0010h, DAC_OR > ... > > CS_DACon ; Active le DAC > ; sort sur DAC numero DAC_OR > LDP #0E0h > LACL SPI_PORT_C1 ; SPISTE &#4294967295; 0 to start the transfer > AND #0BFh > SACL SPI_PORT_C1 > > LDP #DataDAC > LACC DataDAC,8 ; Load data du DataDAC into the Hi ACC > SACH tmp > LACL tmp > AND #000Fh ; Set the DAC control bits (4-7) ou plutot D12-D15 > OR DAC_OR ; DAC voie "DAC_OR", SPD=fast mode > LDP #0E0h > SACL SPI_DAT ; Transmit HI byte > LACL SPI_BUF ; clear le SPI_STATUS,BIT6 : donn&#4294967295;e_envoy&#4294967295; > att1 BIT SPI_STATUS,BIT6 > BCND att1,NTC > LACL SPI_BUF ; clear le SPI_STATUS,BIT6 : donn&#4294967295;e_envoy&#4294967295; > > low_byte > LACL DataDAC ; Read the current value of > AND #0FFh ; data, mask off the lower > LDP #0E0h > SACL SPI_DAT ; Transmit the LOW byte > LACL SPI_BUF ; clear le SPI_STATUS,BIT6 : donn&#4294967295;e_envoy&#4294967295; > > ; transfert fini ? > att2 BIT SPI_STATUS,BIT6 > BCND att2,NTC > LACL SPI_BUF ; clear le SPI_STATUS,BIT6 : donn&#4294967295;e_envoy&#4294967295; > > LACL SPI_PORT_C1 ; en fait : set SPIPC1.6 &#4294967295; 1 => SPISTE pin &#4294967295; 1 ie > latch the Data ! > OR #040h > SACL SPI_PORT_C1 ; latch the data into the DAC > CS_DACoff ; Desactive le DAC > > > where the macro ares : > ---------------------- > CS_DACon .macro > LDP #00E1h > LACC PADATDIR > AND #0FFFDh ; IOPA1 mise &#4294967295; 0 ie DAC activ&#4294967295; > SACL PADATDIR > .endm > CS_DACoff .macro > LDP #00E1h > LACC PADATDIR > OR #0002h ; IOPA1 mise &#4294967295; 1 ie DAC desactiv&#4294967295; > SACL PADATDIR > .endm > > > > I tried to slower the spiclk, to make the 2nd send by spi int, same pb... > the TLV5614 doc say it has a setting time of 3 us ! yes it is true (I > verifed it) but only, if it takes it into account:-) > ??? > > thanks for your kind help > > >
hi again

unfortunately,
what works when I no longer MUX (switch between DACs) ie I set only one DAC,
does not work if I try to through a signal each 100 us on each of the 4
DACs...

it seems complicated... does any one know about MUX time ??? is it more than
some micro-secs ??

thanks




Lotfi wrote:

> hi again > > unfortunately, > what works when I no longer MUX (switch between DACs) ie I set only one DAC, > does not work if I try to through a signal each 100 us on each of the 4 > DACs... > > it seems complicated... does any one know about MUX time ??? is it more than > some micro-secs ?? > > thanks
Do you have a spec sheet? There is not only the MUX switching time to consider, but also the time for the DAC inputs to settle. Depending on the logic speed, the total could be longer than you like. Can you slow the clock for a test? By the way, in "I have a pb to reach ...", what is a pb? Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
"Jerry Avins" <jya@ieee.org> a &#4294967295;crit dans le message news:
4087f381$0$16472$61fed72c@news.rcn.com...
> Lotfi wrote: > > > hi again > > > > unfortunately, > > what works when I no longer MUX (switch between DACs) ie I set only one
DAC,
> > does not work if I try to through a signal each 100 us on each of the 4 > > DACs... > > > > it seems complicated... does any one know about MUX time ??? is it more
than
> > some micro-secs ?? > > > > thanks > > Do you have a spec sheet? There is not only the MUX switching time to > consider, but also the time for the DAC inputs to settle. Depending on > the logic speed, the total could be longer than you like. Can you slow > the clock for a test? >
thank you for your answer
> By the way, in "I have a pb to reach ...", what is a pb? >
the pb is that it works but not at full speed... But I re-looked at my routine friday and... I discovered a software error :-((( I had a pb on a suspicious DataPage initialisation prior to send my 2nd byte... so it workq fine now... by the way, settling time is 3 us and I had verified it it was correct, I also suspected CLK phase and polarity... in fact it was only sending 8 high bytes... so while my variables change to reach a value that changes over 2^8... times is past... so it it vicious... since it seems to work but not completely... Thanks for your support, it helps to see that people are here and may read and give you a kind of help :-) Ciao
"Lotfi" <llbaghli(nospam)@ifrance.com> wrote in message
news:c6jc4s$bh$1@arcturus.ciril.fr...
> > "Jerry Avins" <jya@ieee.org> a &#4294967295;crit dans le message news: > 4087f381$0$16472$61fed72c@news.rcn.com... > > Lotfi wrote: > > > > > hi again > > > > > > unfortunately, > > > what works when I no longer MUX (switch between DACs) ie I set only
one
> DAC, > > > does not work if I try to through a signal each 100 us on each of the
4
> > > DACs... > > > > > > it seems complicated... does any one know about MUX time ??? is it
more
> than > > > some micro-secs ?? > > > > > > thanks > > > > Do you have a spec sheet? There is not only the MUX switching time to > > consider, but also the time for the DAC inputs to settle. Depending on > > the logic speed, the total could be longer than you like. Can you slow > > the clock for a test? > > > > thank you for your answer > > > By the way, in "I have a pb to reach ...", what is a pb? > >
I suspect a 'pb' here refers to a 'problem' :-)...if you haven't figured that out already. Cheers Bhaskar
> the pb is that it works but not at full speed... > But I re-looked at my routine friday and... I discovered a software error > :-((( > I had a pb on a suspicious DataPage initialisation prior to send my 2nd > byte... > so it workq fine now... > by the way, settling time is 3 us and I had verified it it was correct, I > also suspected CLK phase and polarity... > > in fact it was only sending 8 high bytes... so while my variables change
to
> reach a value that changes over 2^8... times is past... so it it
vicious...
> since it seems to work but not completely... > > Thanks for your support, > it helps to see that people are here and may read and give you a kind of > help :-) > Ciao > > > >
Bhaskar Thiagarajan wrote:

   ...

> I suspect a 'pb' here refers to a 'problem' :-)...if you haven't figured > that out already. > > Cheers > Bhaskar
I arrived at that conclusion too. There are plenty of acronyms that people assume everyone knows (but it turns out that I'm not everyone), but it pretty well turns me off when someone who wants my help isn't willing to push the extra keys needed to spell out ordinary words. I'm inclined not to bother with people who are inclined not to bother. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
"Jerry Avins" <jya@ieee.org> wrote in message
news:408d7cf0$0$28899$61fed72c@news.rcn.com...
> Bhaskar Thiagarajan wrote: > > ... > > > I suspect a 'pb' here refers to a 'problem' :-)...if you haven't figured > > that out already. > > > > Cheers > > Bhaskar > > I arrived at that conclusion too. There are plenty of acronyms that > people assume everyone knows (but it turns out that I'm not everyone), > but it pretty well turns me off when someone who wants my help isn't > willing to push the extra keys needed to spell out ordinary words. I'm > inclined not to bother with people who are inclined not to bother.
But you do bother to ask :-)...which kinda defeats your intention of ignoring the OP.
> > Jerry > -- > Engineering is the art of making what you want from things you can get. > &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295; >
On Mon, 26 Apr 2004 17:19:27 -0400, Jerry Avins <jya@ieee.org> wrote:

>Bhaskar Thiagarajan wrote: > > ... > >> I suspect a 'pb' here refers to a 'problem' :-)...if you haven't figured >> that out already. >> >> Cheers >> Bhaskar > >I arrived at that conclusion too. There are plenty of acronyms that >people assume everyone knows (but it turns out that I'm not everyone), >but it pretty well turns me off when someone who wants my help isn't >willing to push the extra keys needed to spell out ordinary words. I'm >inclined not to bother with people who are inclined not to bother. > >Jerry
I agree completely. [-Rick-]
Bhaskar Thiagarajan wrote:

   ...

> But you do bother to ask :-)...which kinda defeats your intention of > ignoring the OP.
I didn't promise to ignore him. I asked because it might just have been a bit of jargon I'm not up on. I find his obtuseness when I did ask amazing. Very little could be a better indication of how far his world is from mine. Lofti: read the part in http://users.erols.com/jyavins/procfaq.htm about cryptic abbreviations. Read the rest, too. Several regulars wrote it. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;