Thank you for your answers.
I am new in my company. I did not participate in the PCB design. Last month, they gave me the board and wanted me to make it work.
The DAC and ADC were both connected to SPI0, and the other two SPI ports were not used.
I asked them why, they sayed that they just did not pay attention to the CPHA configuration.:smileyconfused:
So can we say the PCB was not correctly designed?
Now I create two tasks in my program, AnalogToDigital ( ) and DigitalToAnalog ( ), and use a mutex to protect SPI access (I'm using uC/OS II).
CPHA is configured before I start the transmission.
void AnalogToDigital ( )
{
OSMutexPend();
SPI0_CR1|=0x04;
CS=0;
......
CS=1;
OSMutexPost();
}
void DigitalToAnalog ( )
{
OSMutexPend();
SPI0_CR1&=~0x04;
CS=0;
......
CS=1;
OSMutexPost();
}
It seems to be working, but I'm worried about frequent setting/clearing to the register.