Since 4 weeks, I have been exploring with MC9S08DZ60. I have two queries. I will be specific to the SPI related question here.
I have configured the SPI in Master mode, with Mode fault indication disabled. I am trying to use the Slave Select bit as a GPIO in order to control the pin Manually.
Here's a shabby code which works well to transmit data to the slave. Please find my question below the code snippet.
void SPISendChar (unsigned char data)
while (!SPIS_SPTEF); /* wait until transmit buffer is empty*/
SPID = data; /* Transmit counter*/
void dacfeed(char value)
SPISendChar(value); //To Toggle the SS pin after the Data Transmit is over, I need to wait for delaysmall(50);
void delaysmall(int time)
The flag SPIS_SPTEF goes high immediately (within 2 SPI Clock cycles) . I could observe this through an oscilloscope. So, I need to purposefully introduce a delay with trial and error to make the protocol work suitably for a Slave DAC device. Is there no flag indicating that all the 8 clock cycles are over? Or is there any novel method to write this driver code?
My feeling is that there is some flag indication because the Automatic Slave select works beautifully well.
I would sincerely thank any help provided as I have been struggling a lot throughout this phase.