论坛元老
 
- 积分
- 4370
- 金钱
- 4370
- 注册时间
- 2017-5-30
- 在线时间
- 579 小时
|

楼主 |
发表于 2018-5-7 22:51:20
|
显示全部楼层
发现BUSY 长时间高电平,
void AD7606_Scan(void)
{
uint8_t i;
if (BUSY_IS_LOW())
{
AD_CS_0(); /* SPIƬѡ = 0 */
for (i = 0; i < CH_NUM; i++)
{
s_adc_now[i] = bsp_spiRead1();
s_adc_now[i] = s_adc_now[i] * 256 + bsp_spiRead1();
}
AD_CS_1();
AD7606_StartConv();
}
}
void AD7606_Mak(void)
{
uint8_t i;
int16_t adc;
for (i = 0;i < CH_NUM; i++)
{
s_dat[i] = AD7606_ReadAdc(i);
adc = s_dat[i];
if (g_tAD7606.Range == 0)
{
s_volt[i] = (adc * 5000) / 32767;
}
else
{
s_volt[i] = (adc * 10000) / 32767;
}
}
}
#ifdef SOFT_SPI
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_SCK | RCC_MISO, ENABLE);
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Pin = PIN_SCK;
GPIO_Init(PORT_SCK, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_InitStructure.GPIO_Pin = PIN_MISO;
GPIO_Init(PORT_MISO, &GPIO_InitStructure);
#endif
static void AD7606_ConfigGPIO(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
RCC_APB2PeriphClockCmd(RCC_CS | RCC_RANGE | RCC_BUSY | RCC_RESET | RCC_CONVST, ENABLE);
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Pin = PIN_RESET;
GPIO_Init(PORT_RESET, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = PIN_CONVST;
GPIO_Init(PORT_CONVST, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = PIN_RANGE;
GPIO_Init(PORT_RANGE, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = PIN_CS;
GPIO_Init(PORT_CS, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_InitStructure.GPIO_Pin = PIN_BUSY;
GPIO_Init(PORT_BUSY, &GPIO_InitStructure);
}
|
|