Maker Pro
Maker Pro

SPI between ADS8344 and HCS12

Hi!

I want to readout the analog to digital converter ADS8344 with the
microcontroller ChipS12 (9S12C32), but unfortunately I am an absolute
Beginner in the SPI area.

I'd expect the µC to send out a square (clock) signal at the SCK port
after the following code. But it does not... it sticks at zero.

What is wrong? As long as the ADC doesn't get the clock signal, it
won't convert any voltage to bits. Is it an error instantly
identifiable for an SPI expert?


~~~~~~~CODE~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//Inititalize communication between ADC and æC
DDRM |= 0x38; // set SS,SCK,MOSI lines of the æC to Output
SPIBR = bauddiv; // set SPI Rate

// enable SPI, Master Mode, select clock polarity/phase
SPICR1 = BM_SPE | BM_MSTR | (cpol ? BM_CPOL : 0) | (cpha ? BM_CPHA :
0);
SPICR2 = 0; // as default

// Start SPI communication by sending control byte to the ADC
PTM = PTM & ~0x08; // Bring SS low to select slave
SPIDR = 0x86; // start transfer with Startbit - ch0 - SGL - external
clock
while((SPISR & BM_SPIF) == 0) ; // wait until transfer finished
PTM = PTM | 0x08; // Bring SS high to deselect slave
~~~~~~~CODE~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Clearly the µC doesn't get out of the while-loop as long as no
conversion is being done (which is the case as long as the ADC doesn't
get the clock signal from the µC).

I am very thankful for any idea what-so-ever!

Thanks in advance!
 
Top