The system block is below:
The problem is that when the SPI2 and SPI3 of the RM57L843 receive data from RM42 at the same time, one byte is lost.
In order to facilitate observation, the gio pin state is changed in the start and end interrtup of SPI2 and SPI3.
void vSpi2IrqHandle(void) { uint32 flags = (spiREG2->FLG & 0x0000FFFFU) & (~spiREG2->LVL & 0x035FU); uint32 vec = spiREG2->INTVECT0; ( *( volatile uint32 * )0xFFF7B854UL ) &= ~( 1 << 0 ); // set GPI PIN low switch(vec) { case 0x24U: /* Receive Buffer Full Interrupt */ { spi2_temp0 = (uint8)spiREG2->BUF; my_printf("1 %d\r\n", spi2_temp0); // print to the PC through SCI if(spi2_flg == 0) // In order to remove the first set of data { spi2_flg = 1; } else { if((spi2_last == 5) && (spi2_temp0 == 1)) // the host data send 1 2 3 4 5 In order。 { } else if((spi2_temp0-spi2_last)==1) // To determine whether byte is lost { } else { my_printf("error2\r\n"); while(1); // if lost then stop } } spi2_last = spi2_temp0; break; } case 0x28U: /* Transmit Buffer Empty Interrupt */ { break; } case 0x26U:/*data over Run*/ { my_printf("data over run !\r\n"); break; } default: /* Clear Flags and return */ spiREG2->FLG = 0xFFFF; break; } ( *( volatile uint32 * )0xFFF7B854UL ) |= ( 1 << 0 ); // set gio pin High }
void vSpi3IrqHandle(void) { uint32 flags = (spiREG3->FLG & 0x0000FFFFU) & (~spiREG3->LVL & 0x035FU); uint32 vec = spiREG3->INTVECT0; ( *( volatile uint32 * )0xFFF7B854UL ) &= ~( 1 << 5 ); // set gio pin low switch(vec) { case 0x24U: /* Receive Buffer Full Interrupt */ { spi3_temp0 = (uint8)spiREG3->BUF; my_printf("2 %d\r\n", spi3_temp0); if(spi3_flg == 0) { spi3_flg = 1; } else { if((spi3_last == 5) && (spi3_temp0 == 1)) { } else if((spi3_temp0-spi3_last)==1) { } else { my_printf("error3\r\n"); while(1); } } spi3_last = spi3_temp0; break; } case 0x28U: /* Transmit Buffer Empty Interrupt */ { spiREG3->FLG &= (~(1<<9)); break; } case 0x26U:/*data over Run*/ { my_printf("data over run !\r\n"); spiREG3->FLG &= (~(1<<6)); break; } default: /* Clear Flags and return */ spiREG3->FLG = 0xFFFF; break; } ( *( volatile uint32 * )0xFFF7B854UL ) |= ( 1 << 5 ); // set gio pin high }
oscilloscope wave:
the serial data :
as the code shown above , By observing the oscilloscope and serial data, when the data is lost , the wave just to meet.
I tried a lot of ways, but still did not solve the problem,
Who knows where the problem may be?