Hi Sirs,
I am using two spi port for two serial data output .
One spi work fine on the spi1 or spi2.
The problem happen when spi1 and spi2 work together.
I found the data of spi1 will write to both spi1 and spi2 output, even, the spi2 never write any thing.
My hardware is NUCLEO-F446RE, and my codes is as below:
SPI spi1(PA_7, PA_6, PA_5);
SPI spi2(PB_5, PB_4, PB_3);
void ch1_complete(int event) {
ch1_busy = false;
ch1_transfer();
}
void ch2_complete(int event) {
ch2_busy = false;
ch2_transfer();
}
event_callback_t spi1_complete = ch1_complete; // spi1 complete callback func.
event_callback_t spi2_complete = ch2_complete; // spi2 complete callback func.
uint8_t buf1[32];
uint8_t buf2[32];
void my_spi_init() {
spi1.format(8, 0);
spi2_format(8, 0);
// spi1.set_dma_usage(DMA_USAGE_ALWAYS);
// spi2.set_dma_usage(DMA_USAGE_ALWAYS);
ch1_busy = false;
ch2_busy = false;
}
void ch1_transfer() {
if ( ch1_busy == false && buf1_avaliable ) {
ch1_busy = true;
spi1.transfer<uint8_t>(buf1, sizeof(buf1), NULL, 0, spi1_complete);
}
}
void ch2_transfer() {
if ( ch2_busy == false && buf2_available ) {
ch2_busy = true;
spi2.transfer<uint8_t>(buf2, sizeof(buf2), NULL, 0, spi2_complete);
}
}
Please Help.
BR Jason.