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 =B5C 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 =E6C DDRM |=3D 0x38; // set SS,SCK,MOSI lines of the =E6C to Output SPIBR =3D bauddiv; // set SPI Rate

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

0); SPICR2 =3D 0; // as default

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

Clearly the =B5C 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 =B5C).

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

Thanks in advance!

Reply to
1122
Loading thread data ...

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.