求助
F407 与ADS1293通讯 mosi信号一直为高值位0xff
RCC->AHB1ENR|=1<<1; //ʹÄÜPORTBʱÖÓ
RCC->APB2ENR|=1<<12; //SPI1ʱÖÓʹÄÜ
GPIO_Set(GPIOB,7<<3,GPIO_MODE_AF,GPIO_OTYPE_PP,GPIO_SPEED_100M,GPIO_PUPD_NONE); //PB3~5¸´Óù¦ÄÜÊä³ö
// GPIO_Set(GPIOB,4<<3,GPIO_MODE_AF,GPIO_OTYPE_PP,GPIO_SPEED_100M,GPIO_PUPD_NONE);
GPIO_AF_Set(GPIOB,3,5); //PB3,AF5
GPIO_AF_Set(GPIOB,4,5); //PB4,AF5
GPIO_AF_Set(GPIOB,5,5); //PB5,AF5
//ÕâÀïÖ»Õë¶ÔSPI¿Ú³õʼ»¯
RCC->APB2RSTR|=1<<12; //¸´Î»SPI1
RCC->APB2RSTR&=~(1<<12);//Í£Ö¹¸´Î»SPI1
SPI1->CR1 = 0;
SPI1->CR1 = 0x327;
SPI1->CR2 = 3 << 6;//SPI_CR2_RXNEIE;
SPI1->I2SCFGR = 0;
SPI1->CRCPR = 7;
SPI1->CR1 |= 0x40;
NVIC_SetPriority(SPI1_IRQn, 1);
NVIC_EnableIRQ(SPI1_IRQn);
void SPI1_IRQHandler(void)
{
if(SPI1->SR & SPI_SR_TXE)
{
SPI1->DR = 0x40 | 0x80;
}
if(SPI1->SR & SPI_SR_RXNE)
{
tm = SPI1->DR;
Uart_Send(tm);
}
tm1 = SPI1->SR;
}
|