专家
公告
财富商城
电子网
旗下网站
首页
问题库
专栏
标签库
话题
专家
NEW
门户
发布
提问题
发文章
STM32
STM32的FMSC驱动AD7606问题求助
2019-07-21 02:29
发布
×
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
站内问答
/
STM32/STM8
11455
12
1373
最近在研究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配置对么?你看看配置上有什么错误的地方么。现在感觉是延时出的问题,但我怎么测试都没反应啊
加载中...
1
2
下一页
一周热门
更多
>
相关问题
STM32F4上I2C(在PROTEUS中模拟)调试不通的问题
6 个回答
芯片供应紧张,准备换个MCU,MM32L系列替换STM32L系列的怎么样?
7 个回答
STM32同时使用两个串口进行数据收发时数据丢包的问题
5 个回答
STM32F103串口通信死机问题
4 个回答
STM32WLE5CC连接SX1268在LoRa模式下能与 SX1278互通吗?
2 个回答
STM32开发板免费用活动
7 个回答
stm32 处理 DHT11占用太多时间,大家程序是怎么设计的
8 个回答
分享一个STM32单片机做的离线编程器代码
9 个回答
相关文章
ST公司第一款无线低功耗单片机模块有效提高物联网设计生产效率
0个评论
如何实现对单片机寄存器的访问
0个评论
通过USB用STM32片内自带Bootloader下载程序及注意事项
0个评论
欲练此功必先自宫之STM32汇编启动,放慢是为了更好的前行
0个评论
×
关闭
采纳回答
向帮助了您的网友说句感谢的话吧!
非常感谢!
确 认
×
关闭
编辑标签
最多设置5个标签!
STM32
保存
关闭
×
关闭
举报内容
检举类型
检举内容
检举用户
检举原因
广告推广
恶意灌水
回答内容与提问无关
抄袭答案
其他
检举说明(必填)
提交
关闭
×
关闭
您已邀请
15
人回答
查看邀请
擅长该话题的人
回答过该话题的人
我关注的人
以下是程序部分,大家看看有没有什么问题:
#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();
}
}
---------------------------------
原子哥我的FSMC配置对么?你看看配置上有什么错误的地方么。现在感觉是延时出的问题,但我怎么测试都没反应啊
一周热门 更多>