STM32的FMSC驱动AD7606问题求助

2019-07-21 02:29发布

最近在研究AD7606,但是采样结果怎么弄都与预期的不一样,大家玩过这个片子的可以帮忙看下;
以下是8路采样的结果,
其中第二路的结果应该在0左右就对了;

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
12条回答
飘散的羽
1楼-- · 2019-07-21 05:02
好了,问题解决了,在MAIN里面,开始转换后需要加一个100US的延迟,这样才能将全部的采样结果保存在BUF里面。看时序的时候发现的。
飘散的羽
2楼-- · 2019-07-21 08:22
 精彩回答 2  元偷偷看……
飘散的羽
3楼-- · 2019-07-21 10:14

以下是程序部分,大家看看有没有什么问题:
#include "ad7606.h"
#include "delay.h"
#include "stm32f10x.h"


#define CONVST_1()        GPIOB->BSRR = GPIO_Pin_7
#define CONVST_0()        GPIOB->BRR = GPIO_Pin_7

#define RESET_1()        GPIOB->BSRR = GPIO_Pin_6
#define RESET_0()        GPIOB->BRR = GPIO_Pin_6



#define AD7606_RESULT()        *(__IO uint16_t *)0x6C400000

AD7606_VAR_T g_tAD7606;               


static void AD7606_CtrlLinesConfig(void);
static void AD7606_FSMCConfig(void);



void AD7606_Init(void)
{
        AD7606_CtrlLinesConfig();
        AD7606_FSMCConfig();

        AD7606_Reset();
        CONVST_1();                               
}


static void AD7606_CtrlLinesConfig(void)  
{
        GPIO_InitTypeDef        GPIO_InitStructure;
       
        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);

        RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE | RCC_APB2Periph_GPIOG, ENABLE);
       
       
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 |GPIO_Pin_8 | GPIO_Pin_9 |
                                                                                                                                GPIO_Pin_10 | GPIO_Pin_14 | GPIO_Pin_15;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_Init(GPIOD, &GPIO_InitStructure);
       
/*
                E.07(D4), E.08(D5), E.09(D6), E.10(D7), E.11(D8), E.12(D9), E.13(D10),
                 E.14(D11), E.15(D12)
        */
               
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 |
                                    GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 |
                                    GPIO_Pin_15;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_Init(GPIOE, &GPIO_InitStructure);
       
   /*!< NOE and NWE configuration */
   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;   // | GPIO_Pin_5;
         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
         GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
   GPIO_Init(GPIOD, &GPIO_InitStructure);
       
        /* NE4 configuration */
       
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_Init(GPIOG, &GPIO_InitStructure);
               

//PB7/AD7606_CONVST      ---> AD7606_CONVST
//PB6/AD7606_RESET        ---> AD7606_RESET       
//PB9/AD7606_BUSY                        ---> AD7606_BUSY   
//PB8/AD7606_FRSTDATA   ---->AD7606_FRSTDATA               
                GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
                GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
                GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
                GPIO_Init(GPIOB, &GPIO_InitStructure);
               
                GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 ;//| GPIO_Pin_8;
                GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
                GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
                GPIO_Init(GPIOB, &GPIO_InitStructure);
}


static void AD7606_FSMCConfig(void)
{
        FSMC_NORSRAMInitTypeDef  init;
        FSMC_NORSRAMTimingInitTypeDef  timing;
       
        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC,ENABLE);

        /* FSMC_Bank1_NORSRAM4 configuration */
        timing.FSMC_AddressSetupTime = 3;
        timing.FSMC_AddressHoldTime = 0;
        timing.FSMC_DataSetupTime = 5;
        timing.FSMC_BusTurnAroundDuration = 1;
        timing.FSMC_CLKDivision = 0;
        timing.FSMC_DataLatency = 0;
        timing.FSMC_AccessMode = FSMC_AccessMode_A;
       
        init.FSMC_Bank = FSMC_Bank1_NORSRAM4;
        init.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
        //init.FSMC_MemoryType = FSMC_MemoryType_NOR;
        init.FSMC_MemoryType = FSMC_MemoryType_SRAM;
        init.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
        init.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
        init.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
        init.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
        init.FSMC_WrapMode = FSMC_WrapMode_Disable;
        init.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
        init.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
        init.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
        init.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
        init.FSMC_WriteBurst = FSMC_WriteBurst_Disable;

        init.FSMC_ReadWriteTimingStruct = &timing;
        init.FSMC_WriteTimingStruct = &timing;

        FSMC_NORSRAMInit(&init);

        /* - BANK 1 (of NOR/SRAM Bank 1~4) is enabled */
        FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM4, ENABLE);
}





void AD7606_Reset(void)
{

        RESET_0();       

        RESET_1();       
        RESET_1();       
        RESET_1();
        RESET_1();

        RESET_0();       
}



void AD7606_StartConvst(void)
{
       
       
       
        CONVST_0();
        CONVST_0();
        CONVST_0();

        CONVST_1();

}
这是MAIN 函数


int main(void)
{

        delay_init();                   
        NVIC_Configuration();          
        FSMC_SRAM_Init();
        LED_Init();               
        uart_init(9600);       
        AD7606_Init();       
        TIM3_Int_Init(4999,7199);
       

  while (1)
  {
        //delay_ms(500);       
        AD7606_StartConvst();               
                        delay_us(25);       
        AD7606_ReadNowAdc();               


        delay_ms(500);       
       
               
        //        printf("%d,",g_tAD7606.sNowAdc[0]);
  //                                                g_tAD7606.sNowAdc[0], g_tAD7606.sNowAdc[1],
                printf("CH1 = %6d, CH2 = %6d, CH3 = %6d, CH4 = %6d, ",
                                                  g_tAD7606.sNowAdc[0], g_tAD7606.sNowAdc[1], g_tAD7606.sNowAdc[2], g_tAD7606.sNowAdc[3]);
                printf("CH5 = %6d, CH6 = %6d, CH7 = %6d, CH8 = %6d ",
                                                   g_tAD7606.sNowAdc[4], g_tAD7606.sNowAdc[5], g_tAD7606.sNowAdc[6], g_tAD7606.sNowAdc[7]);
                        delay_us(25);       
//         AD7606_Reset();               

  }
}
飘散的羽
4楼-- · 2019-07-21 12:59
原子哥有遇到这种问题吗?求教啊
正点原子
5楼-- · 2019-07-21 14:06
 精彩回答 2  元偷偷看……
飘散的羽
6楼-- · 2019-07-21 16:28
回复【5楼】正点原子:
---------------------------------
原子哥我的FSMC配置对么?你看看配置上有什么错误的地方么。现在感觉是延时出的问题,但我怎么测试都没反应啊

一周热门 更多>