Daniel Lundin

HCS08DZ60, peculiar SPI problem

Discussion created by Daniel Lundin on Jan 14, 2008
Latest reply on Jan 21, 2008 by Andrew Glossop
I'm using HCS08DZ60 on EVB9S08DZ from Softec, with CW6.0.

The HCS08 is master and we are trying to contact a SPI slave device but cannot get it working. On the hardware level, everything is working correctly. The MOSI line sends the correct data and I get the correct response from the external circuit on the MISO pin of the mcu.

But when I read the SPI data register, the data shows up as 0xFF. That is when I have SSOE=1, if I set the /SS pin manually instead, the SPI data shows up as 0x00.

Now, if I let the program run and send several commands, I do get the right values in the SPID. So there seems to be a problem with the first byte of data sent/received. I have tried various clock settings with CPHA and CPOL, but no combination works.

void SPI_init ( SPI_Baudrate baud){

SPIC1 = 0x5E; //SPIE=0;SPE=1;SPTIE=0;MSTR=1;CPOL=1;CPHA=1;SSOE=1;LSBFE=0

SPIC2 = 0x12; //0; 0; 0; MODFEN=1 ; BIDIROE=0 ;0 ;SPISWAI=1 ;SPCO=0
SPIBR = (uint8)baud;
}


uint8 SPI_transfer(uint8 data1, uint8 data2){

volatile uint8 x;

// PTED = 0x00; // SS low

while(SPIS_SPTEF == 0) //wait until transmitter empty
;
SPID = data1; //send data1

while(SPIS_SPTEF == 0) //wait until transmitter empty
;

SPID = data2; //send data2

while (SPIS_SPRF == 0) //wait until receiver is full
;
x= SPID; //read data register

// PTED = 0x04; // SS high

return x;

}


I remember similar problems on the HCS12, which was then caused by silicon bugs. I can't find any errata for the S08 SPI though, is there one for silicon mask 1M05C?

Outcomes