I am using the DAC8581. I specified PM3 to be a regular I/O pin for CS.
And here is the code for the transfer data:
#define SPIF 0x80
void DAC_out(unsigned short code)
{
unsigned char dummy;
PTM &= ~0x08; // PM3=CS=0
while((SPISR&0x20)==0); // wait for SPTEF
SPIDR = (code>>8); // msbyte
while((SPISR&SPIF)==0); // gadfly wait
dummy = SPIDR; // clear SPIF
while((SPISR&0x20)==0); // wait for SPTEF
SPIDR = code; // lsbyte
while((SPISR&SPIF)==0); // gadfly wait
dummy = SPIDR; // clear SPIF
PTM |= 0x08; // PM3=CS=1
}
The main problem is that the PM5/SCK pin isn't giving me a clock signal. I had the MCU tested to see if there were any problems with the SPI ports and none were found.