我设置开发板的SP1为从模式,SP2为主模式。并且用杜邦线将sp1与sp2连起来,SP2循环发送发送0x01-0x20,但是sp1中断收不到数据,并且中断里SPI_IT_MODF会变成SET。已经卡了好几天了,实在找不出问题出在哪里。求好心人帮忙。
代码如下:
main文件:int main(void)
{
//嵌套向量终端控制器组选择
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
BASIC_TIM_Init();
LED_GPIO_Config();
USART_Config();
Usart_SendByte(DEBUG_USARTx,88);
SPI_M_Init();
SPI_S_Init();
u8 SPI_M_Buffer_Tx[32] = /* 定义待 SPI-master 传输数据 */
{
0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,
0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x10,
0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,
0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,0x20
};
u8 SPI_M_Buffer_Rx[32];
u8 RxSP=0;
while(1)
{
M_SPI_CS_LOW();
for(int i=0;i<32;i++)
{
SPI_M_Buffer_Rx=M_SPI_SendByte(SPI_M_Buffer_Tx);
}
M_SPI_CS_HIGH();
SOFT_DELAY;
}
while(1)
{
LED1_ON;
SOFT_DELAY;
LED1_OFF;
LED3_ON;
SOFT_DELAY
LED3_OFF;
LED2_ON;
SOFT_DELAY
LED2_OFF;
};
} |