Reply by cron...@ananzi.co.za●August 29, 20092009-08-29
Hi Dr. Mike,
Thanks for the response, I measured the other method of programing the codec on
the oscilloscope as you suggested and it worked well, I was able to exactly
replicate the signals to the codec. The codec still refused to work! I then
searched on the analog site and found that there was an SPI anomally for the
earlier releases of the codec and I replaced the IC with a newer released codec
and now its working.
Regards,
Allan
Reply by Mike Rosing●August 28, 20092009-08-28
On Fri, 28 Aug 2009, c...@ananzi.co.za wrote:
> Hi All,
> I have read the previous posts stating that SPTINT and SPRINT need to
>be initialised to work as well as requiring a dummy read for every write
>but my SPI still seems to not be working. I am trying to program the
>AD1836 codec through SPI on my ADSP21161N EZ KIT Lite, has anyone managed
>to do this before? I cant use the SPI emulation with the SPORTs in my
>application so I require SPI. Analog Devices has sample code that comes
>with EE-194 for SPI programing but its terribly buggy (no dummy reads), I
>wrote my own code that should work, infact when I measure on an
>oscilloscope I get what im expecting but the codec refuses to work. The
>codec works fine with SPI emulation so its still working. Im also trying
Use the scope and compare the differences between what works and what
doesn't. Your code may be fine, but there might be timing tolerances
that
the simulation can't even come close to but the SPI is just running too
fast for the codec.
Patience, persistence, truth,
Dr. mike
Reply by cron...@ananzi.co.za●August 28, 20092009-08-28
Hi All,
I have read the previous posts stating that SPTINT and SPRINT need to be
initialised to work as well as requiring a dummy read for every write but my SPI
still seems to not be working. I am trying to program the AD1836 codec through
SPI on my ADSP21161N EZ KIT Lite, has anyone managed to do this before? I cant
use the SPI emulation with the SPORTs in my application so I require SPI. Analog
Devices has sample code that comes with EE-194 for SPI programing but its
terribly buggy (no dummy reads), I wrote my own code that should work, infact
when I measure on an oscilloscope I get what im expecting but the codec refuses
to work. The codec works fine with SPI emulation so its still working. Im also
trying to program a SPI LCD that refuses to work so Im assuming im making the
same mistake between both of them, if someone could please browse through my
code and tell me if they spot anything wrong it would be greatly appreciated! or
if someone has done this before some help would be great, thanks in advance.
heres my SPI function I call to setup the codec:
// Disable the SPI Port and flush the transceive FIFOs
r0 = 0;
dm(SPICTL) = r0;
leaf_exit;
_Program_AD1836_regs_via_SPI.end: rts;
_WriteAD1836A:
// clear flag 0 to select the SPI slave port.
bit clr FLAGS FLG0;
nop;
// send the value to the AD1836
r0 = dm(value);
call _TxAD1836SPI;
// set flag 0 to deselect the SPI slave port.
bit set FLAGS FLG0;
nop;
rts;
// Transmits the data available on r0 to the AD1836 using SPI port
_TxAD1836SPI:
//write to the SPITX register to start transfer
dm(SPITX) = r0;
//wait for 100 cycles
lcntr = 100, do delay until lce;
delay: nop;
// poll the SPIF bit of the SPISTAT register and wait for the transfer to
complete.
r2 = SPIF;
poll_spistatus:
r1 = dm(SPISTAT);
r1 = r1 and r2;
if eq jump poll_spistatus;
//wait for 100 cycles
lcntr = 100, do delay1 until lce;
delay1: nop;
// dummy read to receive the data on the SPI receiver.
r2 = dm(SPIRX);
dm(dummy) = r2;