查看: 1307|回复: 0

【Eval-ADuCM360MKZ评估板】ADI公司24bits的ADC(一):开箱+新建工程+测试

[复制链接]
  • TA的每日心情
    无聊
    2016-10-8 20:34
  • 签到天数: 10 天

    连续签到: 1 天

    [LV.3]偶尔看看II

    发表于 2016-8-22 09:20:26 | 显示全部楼层 |阅读模式
    分享到:
    先上ADuCM360数据手册上封面介绍的特性:

    看这个特性,就感觉这个芯片很有特点:高精度ADC + Cortex-M3微控制器!用来做智能精密检测应该很适合。
    评估板Eval-ADuCM360MKZ上有一个PT100电阻,可以用来做高精度温度检测,见爱板网评测“一款高精度的单芯片温度测量参考方案——ADI EVAL-ADuCM360QSPZ开发套件评测
    板子到手后,老套路,①开箱,②上电测试,③建立工程模板;
    ①开箱:
        开箱,拍照,留个纪念;
    ②上电测试:
        给板子插上USB,到光盘资料里找个程序下载一下试一下,能下载,没有什么问题;
    ③建立工程模板
        按照自己的风格建立一个工程模板,以便于后续编程;工程模板里把时钟配置,延时函数,LED指示,串口打印等做好;
    详细过程如下:
    ①开箱拍个照;

    板子很小,只有一个电源芯片+最小系统+LED+PT100,评估套自带JLINK;
    ②上电并下个程序测试一下;
    板子的资料在ADI官网aducm360资料页面和随板子一起的光盘里有,到里面随便找一个程序,下载一下,能下载,没有什么问题;

    ③按照自己的风格建立一个工程模板,以便于后续编程;
    自己的风格:

    按自己风格建立工程模板的时候,顺便在心里理顺一下ADI库中各个文件的作用和思路;
    建立工程模板的时候,顺便把以后必用的时钟配置,延时函数,LED指示,串口打印做好;
    clock.c
    /**  ******************************************************************************  * @file    clock.c  * @author  YangJie  * @version V0.0  * @date    2016-8-21  * @brief   clock config  ******************************************************************************  * @attention  ******************************************************************************  *//* Includes ------------------------------------------------------------------*/#include        "clock.h"/* Private typedef -----------------------------------------------------------*//* Private define ------------------------------------------------------------*//* Private macro -------------------------------------------------------------*//* Private variables ---------------------------------------------------------*//* Private function prototypes -----------------------------------------------*//* Private functions ---------------------------------------------------------*//**  * @brief  Clk_Init  * @param  None  * @retval None  * @brief  初始化时钟配置  */void Clk_Init(void){   ClkCfg(CLK_CD0,               // CLK_CD0 to divide clock by 1          CLK_HF,                // CLK_HF for 16MHz clock          CLKSYSDIV_DIV2EN_DIS,  // CLKSYSDIV_DIV2EN_DIS for 16MHz clock when internal HF oscillator is selected          CLK_UCLKCG             // CLK_UCLKCG to output UCLKCG clock         );}clock.h/**  ******************************************************************************  * @file    clock.h  * @author  YangJie  * @version V0.0  * @date    2016-8-21  * @brief   clock config  ******************************************************************************  * @attention  ******************************************************************************  *//* Define to prevent recursive inclusion -------------------------------------*/#ifndef __CLOCK_H#define __CLOCK_H/* Includes ------------------------------------------------------------------*/#include        "ClkLib.h"#include <ADuCM360.h>/* Exported functions ------------------------------------------------------- */void Clk_Init(void);   #endif
    delay.c
    /**  ******************************************************************************  * @file    delay.c  * @author  YangJie  * @version V0.0  * @date    2016-8-21  * @brief   delay function  ******************************************************************************  * @attention  ******************************************************************************  *//* Includes ------------------------------------------------------------------*/#include        "delay.h"/* Private typedef -----------------------------------------------------------*//* Private define ------------------------------------------------------------*//* Private macro -------------------------------------------------------------*//* Private variables ---------------------------------------------------------*/static uint8_t  fac_us=0;                                                        // us延时倍乘数                           static uint16_t fac_ms=0;                                                        // ms延时倍乘数/* Private function prototypes -----------------------------------------------*//* Private functions ---------------------------------------------------------*/  /**  * @brief  delay_init  * @param  None  * @retval None  * @brief  初始化延时函数  */                           void delay_init(){   SystemCoreClockUpdate();   SysTick->CTRL |= SysTick_CTRL_CLKSOURCE_Msk; // Enable SysTick Timer Clock   fac_us = SystemCoreClock / 1000000;                                // 每个us需要的systick时钟数      fac_ms = (uint16_t)fac_us * 1000;                           // 每个ms需要的systick时钟数   }                                                                    /**  * @brief  delay_us  * @param  nus:需要延时的us数  * @retval None  * @brief  延时nus  */                                                                                       void delay_us(uint32_t nus){                        uint32_t temp;                             SysTick->LOAD=nus*fac_us;                                            //时间加载                                   SysTick->VAL=0x00;                                                   //清空计数器        SysTick->CTRL|=SysTick_CTRL_ENABLE_Msk ;        //开始倒数                  do        {                temp=SysTick->CTRL;        }while((temp&0x01)&&!(temp&(1<<16)));                //等待时间到达           SysTick->CTRL&=~SysTick_CTRL_ENABLE_Msk;        //关闭计数器        SysTick->VAL =0X00;                                                 //清空计数器         }/**  * @brief  delay_ms  * @param  nms:需要延时的us数  * @retval None  * @brief  延时nms  *         系统时钟16MHz情况下最大可延时1048ms  */void delay_ms(uint16_t nms){                                             uint32_t temp;                           SysTick->LOAD=(uint32_t)nms*fac_ms;              //时间加载(SysTick->LOAD为24bit)        SysTick->VAL =0x00;                                                           //清空计数器        SysTick->CTRL|=SysTick_CTRL_ENABLE_Msk ;        //开始倒数          do        {                temp=SysTick->CTRL;        }while((temp&0x01)&&!(temp&(1<<16)));                //等待时间到达           SysTick->CTRL&=~SysTick_CTRL_ENABLE_Msk;        //关闭计数器        SysTick->VAL =0X00;                                                  //清空计数器                      } delay.h/**  ******************************************************************************  * @file    delay.h  * @author  YangJie  * @version V0.0  * @date    2016-8-21  * @brief   delay function  ******************************************************************************  * @attention  ******************************************************************************  *//* Define to prevent recursive inclusion -------------------------------------*/#ifndef __DELAY_H#define __DELAY_H /* Includes ------------------------------------------------------------------*/#include <ADuCM360.h>/* Exported functions ------------------------------------------------------- */void delay_init(void);void delay_ms(uint16_t nms);void delay_us(uint32_t nus);#endifLED.c/**  ******************************************************************************  * @file    LED.c  * @author  YangJie  * @version V0.0  * @date    2016-8-21  * @brief   LED function  ******************************************************************************  * @attention  ******************************************************************************  *//* Includes ------------------------------------------------------------------*/#include        "LED.h"/* Private typedef -----------------------------------------------------------*//* Private define ------------------------------------------------------------*//* Private macro -------------------------------------------------------------*//* Private variables ---------------------------------------------------------*//* Private function prototypes -----------------------------------------------*//* Private functions ---------------------------------------------------------*/  /**  * @brief  LED_Init  * @param  None  * @retval None  * @brief  初始化LED引脚,LED连接在P1.3  */                           void LED_Init(void){   DioCfgPin(pADI_GP1,  // pADI_GP0 for GP0             PIN3,      // PIN2 to configure Px.2             0          // 0 is choice to work as GPIO             );      DioOenPin(pADI_GP1,PIN3,1);   // 1 to configure as an output   DioPulPin(pADI_GP1,PIN3,1);   // 1 to enable the pull up}LED.h
    /**  ******************************************************************************  * @file    LED.h  * @author  YangJie  * @version V0.0  * @date    2016-8-21  * @brief   LED function  ******************************************************************************  * @attention  ******************************************************************************  *//* Define to prevent recursive inclusion -------------------------------------*/#ifndef __LED_H#define __LED_H #define LED_off() pADI_GP1->GPSET = 1<<3#define LED_on()  pADI_GP1->GPCLR = 1<<3/* Includes ------------------------------------------------------------------*/#include <ADuCM360.h>#include "DioLib.h"/* Exported functions ------------------------------------------------------- */void LED_Init(void);#endif串口直接使用光盘资料里的Serial.c和Retarget.c
    main.c
    /**  ******************************************************************************  * @file    main.c  * @author  YangJie  * @version V0.0  * @date    2016-8-21  * @brief   Main program body  ******************************************************************************  * @attention  ******************************************************************************  *//* Includes ------------------------------------------------------------------*/#include <stdio.h>#include <string.h>#include <ADuCM360.h>#include        "clock.h"#include "Serial.h"#include        "delay.h"#include        "LED.h"/* Private typedef -----------------------------------------------------------*//* Private define ------------------------------------------------------------*//* Private macro -------------------------------------------------------------*//* Private variables ---------------------------------------------------------*//* Private function prototypes -----------------------------------------------*//* Private functions ---------------------------------------------------------*//**  * @brief  Main program.  * @param  None  * @retval None  */int main(void){   Clk_Init();    SER_Init();   delay_init();   LED_Init();      printf ("\n\r\n\r初始化成功!\n\r\n\r");      /* Infinite loop */   while (1)   {      static uint8_t i = 0;            LED_on();      printf ("\n\rHello World --- %d\n\r",i++);      delay_ms(1000);      LED_off();      printf ("\n\rHello World --- %d\n\r",i++);      delay_ms(1000);   }}
    工程模板编好后,下载测试一下,延时函数基本准确,LED可以闪烁,串口可以正常打印;

    至此,工程模板已经可用,下一步可以测试板上的设备,再利用板上的设备做一些东西了。
    回复

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /2 下一条

    手机版|小黑屋|与非网

    GMT+8, 2024-4-20 09:09 , Processed in 0.132705 second(s), 18 queries , MemCache On.

    ICP经营许可证 苏B2-20140176  苏ICP备14012660号-2   苏州灵动帧格网络科技有限公司 版权所有.

    苏公网安备 32059002001037号

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.