各位大侠,我用的是
STM32f105的
ARM 现在调试 一个ads1243 片子用的是spi口现在是发送数据是没问题的,但是怎么都读不到ads1243的信息,找不到原因谁能帮忙下,谢谢
SPI_InitTypeDef SPI_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
/******************************MISO**************************************/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOA
tiNG;//GPIO_Mode_IPU;//GPIO_Mode_IN_FLOATING;//GPIO_Mode_AIN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/*****************************MOSI AND SCK********************************/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7|GPIO_Pin_5;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/*****************************NSS******************************************/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
// GPIO_ResetBits(GPIOA,GPIO_Pin_4);
CSH;
SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;//SPI_DataSize_8b;
SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;//SPI_NSS_Hard;//
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_64;//SPI_BaudRatePrescaler_4; // 9MʱÖÓ
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;// SPI_FirstBit_LSB;//
SPI_InitStructure.SPI_CRCPolynomial = 7;
SPI_Init(SPI1,&SPI_InitStructure);
// SPI_I2S_ITConfig(SPI1,SPI_I2S_IT_RXNE,ENABLE); // ʹÄܽÓÊÕÖжÏ
// SPI_I2S_ITConfig(SPI1,SPI_I2S_IT_TXE,ENABLE); // ʹÄÜ·¢ËÍÖжÏ
SPI_Cmd(SPI1,ENABLE);
一周热门 更多>