求大伙帮我看一下这个SPI的配置哪里出了问题

2019-07-19 21:32发布

我想用两个STM8S单片机实现SPI通讯,主机的程序为:
[mw_shl_code=c,true]int main(void) { CLK_HSICmd(ENABLE); CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1); /*设置内部时钟16M为主时钟*/ GPIO_Init(GPIOC, GPIO_PIN_5, GPIO_MODE_OUT_PP_HIGH_FAST); GPIO_Init(GPIOC, GPIO_PIN_6, GPIO_MODE_OUT_PP_HIGH_FAST); GPIO_Init(GPIOC, GPIO_PIN_7, GPIO_MODE_IN_FL_NO_IT); SPI_DeInit(); SPI_Init(SPI_FIRSTBIT_MSB, SPI_BAUDRATEPRESCALER_256, SPI_MODE_MASTER, SPI_CLOCKPOLARITY_LOW, SPI_CLOCKPHASE_2EDGE, SPI_DATADIRECTION_1LINE_TX, SPI_NSS_HARD, 0x07); SPI_Cmd(ENABLE); while (1) { SPI_SendData(0x88); delay_ms(4000); } }[/mw_shl_code] 从机的程序为: [mw_shl_code=c,true]int main(void) { CLK_HSICmd(ENABLE); CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1); /*设置内部时钟16M为主时钟*/ Uart_Init(); GPIO_Init(GPIOC, GPIO_PIN_5, GPIO_MODE_OUT_PP_HIGH_FAST); GPIO_Init(GPIOC, GPIO_PIN_6, GPIO_MODE_IN_FL_NO_IT); GPIO_Init(GPIOC, GPIO_PIN_7, GPIO_MODE_OUT_PP_HIGH_FAST); SPI_DeInit(); SPI_Init(SPI_FIRSTBIT_MSB, SPI_BAUDRATEPRESCALER_256, SPI_MODE_SLAVE, SPI_CLOCKPOLARITY_LOW, SPI_CLOCKPHASE_2EDGE, SPI_DATADIRECTION_1LINE_RX, SPI_NSS_HARD, 0x07); SPI_Cmd(ENABLE); while (1) { while(SPI_GetFlagStatus(SPI_FLAG_RXNE) == SET); printf("%d",SPI_ReceiveData()); delay_ms(4000); } }[/mw_shl_code] 但是在串口那边收到的一直是零,这是哪里配置出了问题呢
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。