-
GD32F305SPI没有时钟信号
使用了官方例程,芯片也换过,用示波器就是没检测到sck信号 而且使用这个历程之后到spi0_receive_array[receive_cnt]= spi_i2s_data_receive(spi0_send_array[send_cnt]);这行代码就不能往下执行了,send_n只接收一次 下面是代码 这是SPI的配置spi.c #include "SPI.h" #include "gd32f30x_spi.h" #include "systick.h" void spi0_init(void) { rcu_periph_clock_enable(RCU_GPIOA); rcu_periph_clock_enable(SPI0); rcu_periph_clock_enable(RCU_AF); /*SCK->PA5 MISO->PA6 MOSI->PA7 SPI1:MASTER*/ gpio_init(GPIOA, GPIO_MODE_AF_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_5 | GPIO_PIN_7); gpio_init(GPIOA, GPIO_MODE_IN_FLOATING, GPIO_OSPEED_50MHZ, GPIO_PIN_6); spi_parameter_struct spi_init_struct; spi_i2s_deinit(SPI0); spi_init_struct.trans_mode = SPI_TRANSMODE_FULLDUPLEX; spi_init_struct.device_mode = SPI_MASTER; spi_init_struct.nss = SPI_NSS_SOFT; spi_init_struct.clock_polarity_phase = SPI_CK_PL_LOW_PH_1EDGE; spi_init_struct.frame_size = SPI_FRAMESIZE_8BIT; spi_init_struct.endian = SPI_ENDIAN_MSB; spi_init_struct.prescale = SPI_PSC_8; spi_enable(SPI0); } void spi1_init(void) { rcu_periph_clock_enable(RCU_GPIOB); rcu_periph_clock_enable(SPI1); rcu_periph_clock_enable(RCU_AF); /*SCK->PB13 MISO->PB14 MOSI->PB15 SPI1:SLAVE*/ gpio_init(GPIOB, GPIO_MODE_AF_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_13 | GPIO_PIN_14); gpio_init(GPIOB, GPIO_MODE_IN_FLOATING, GPIO_OSPEED_50MHZ, GPIO_PIN_15); spi_parameter_struct spi_init_struct; spi_i2s_deinit(SPI1); spi_init_struct.trans_mode = SPI_TRANSMODE_FULLDUPLEX; spi_init_struct.device_mode = SPI_SLAVE; spi_init_struct.nss = SPI_NSS_SOFT; spi_init_struct.clock_polarity_phase = SPI_CK_PL_LOW_PH_1EDGE; spi_init_struct.frame_size = SPI_FRAMESIZE_8BIT; spi_init_struct.endian = SPI_ENDIAN_MSB; spi_enable(SPI1); } 下面是主函数的代码 main.c #include "gd32f30x.h" #include "systick.h" #include "Alarm.h" #include "SPI.h" extern void Task_Init(void); extern void Task_Idle(void); extern void spi1_init(void); #define NUM 10 unsigned char spi0_send_array[NUM] = {0x00A1,0x00A2,0x00A3,0x00A4,0x00A5,0x00A6,0x00A7,0x00A8,0x00A9,0x00AA}; unsigned char spi1_send_array[NUM] = {0x00B1,0x00B2,0x00B3,0x00B4,0x00B5,0x00B6,0x00B7,0x00B8,0x00B9,0x00BB}; unsigned char spi0_receive_array[NUM]; unsigned char spi1_receive_array[NUM]; unsigned char send_cnt, receive_cnt; int main(void) { systick_config(); spi0_init(); spi1_init(); while(send_cnt
1982浏览量 4回复量 关注量