⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sd16.c

📁 FE42X单相防窃电电表DEMO(编译器 AQ430 AQ430 V2.0.6.5)
💻 C
字号:
/********************************************************************************
*					           杭州利尔达                                       *
*                 MSP430FE42X单相防窃电多功能电表平台                           *
*                          -----  ESP SD16实现                                  *
*                                                                               *
*                                                                               *
* 说明:本软件为杭州利尔达单相防窃电多功能电表DEMO软件                          *
*                                                                               *
*********************************************************************************/

#include "msp430xe42x.h"
#include "globe.h"
#include "emeter_cfg.h"
#include "extern_function.h"


/* The following are the front end gains to be used for an SD16's three ADCs */
#define CURRENT_CH_1_GAIN                   SD16GAIN_1
#define CURRENT_CH_2_GAIN                   SD16GAIN_16
#define VOLTAGE_CH_GAIN                     SD16GAIN_1

#define SD16CONF0_FUDGE     0xC0
#define SD16CONF1_FUDGE     0x40

/*
 * Analog front-end initialization routine.
 *
 * Configures the sigma-delta ADC module as analog front-end for
 * a tamper-resistant meter using a current transformer and a
 * shunt as current sensors (see configuration of channel 0 and 1).
 */
void init_analog_front_end_SD16(void)
{
    /*
     * First it makes sure that the Embedded Signal Processing is 
     * disabled, otherwise it will not be possible to modify the 
     * SD16 registers.
     */
    ESPCTL &= ~ESPEN;

    /*
     * Then the general configurations of the analog front-end are done
     * that apply to all channels: clock selection (SMCLK) and divider
     * settings (depending on SMCLK frequency) and reference voltage
     * selections.
     */
    SD16CTL = 0x800
    		| SD16SSEL_1  /* Clock is SMCLK */
            | SD16DIV_2   /* Divide by 8 => ADC clock: 1.048576MHz */
            | SD16REFON  /* Use internal reference */
            | SD16LP;

    /* 
     * For the configuration of the analog front-end channel 0 (Current 1)
     * the following example is used: 
     * \par Current transformer
     * (e.g. T60404-E4623-X101 from VAC (http://www.vacuumschmelze.com))
     * - Turn ratio: 2500
     * - Burden resistor: RB = 18.8Ohm
     * - Phase error at 50Hz: 4.15

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -