亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? emeter.c

?? 430系列開發之MSP430FE42x開發代碼實例
?? C
?? 第 1 頁 / 共 2 頁
字號:
//#define WFS

/** \file 
  * ESP430CE1 Application Program Example
  *
  * This file shows exemplarily the usage of the ESP430CE1 module for
  * a single-phase emeter with two current sensors (one shunt and one
  * current transformer).
  *
  * \author Volker Rzehak
  * \date   04/08/2003
  *
  * \Modified Stefan Schauer
  * \date   04/29/2003
  */
//====================================================================

#include "device.h"
#include "emeter.h"
#include "parameter.h"
#include "display.h"


#if __VER__ < 200
sfrb    SD16CONF0          = 0xB7;
sfrb    SD16CONF1          = 0xBF;
#else
#define SD16CONF0_                (0xB7)  
DEFC(   SD16CONF0               , SD16CONF0_)
#define SD16CONF1_                (0xBF)  
DEFC(   SD16CONF1               , SD16CONF1_)
#endif

// const and var definition

unsigned char ZXLDFGedge = 0;

/// Saves firmware version during initialization.
unsigned int firmware_version; 
/// Cumulated active energy.
float total_energy;
/// Last temperature measurement result.
unsigned int temperature;

// buffer to save RET values
unsigned int savedRET[(RET31_ - RET0_)/2];

//union tu_ulong_word intlevel = {pSET_INTRPTLEVL_LO, pSET_INTRPTLEVL_HI};
struct ts_parameters s_parameters;

#ifdef __IAR_SYSTEMS_ICC__
#if __VER__ < 200
#pragma memory=constseg(INFOA)
#else
#pragma constseg=INFOA
#endif
#endif

#ifdef __CROSSWORKS__
#pragma constseg("INFOA")
#endif

const struct ts_parameters s_parameters_flash = 
           {
              defVRatio,
              defIRatio,
              defEnergieRatio,
              defSET_PHASECORR1,
              defSET_PHASECORR2,
              defSET_V1OFFSET,
              defSET_I1OFFSET,
              defSET_I2OFFSET,
              defSET_STARTCURR_INT,
              defSET_STARTCURR_FRAC,
              {defSET_INTRPTLEVL_LO,
               defSET_INTRPTLEVL_HI},
              def_togglelevel,
           };
#ifdef __IAR_SYSTEMS_ICC__
#if __VER__ < 200
#pragma memory=default
#else
#pragma constseg=default
#endif
#endif

#ifdef __CROSSWORKS__
#pragma dataseg(default)
#endif

unsigned int CalCyclCnt = 0;     // Register for Cycle calculation of Calibration
unsigned int wfs1;
unsigned int wfs2;
unsigned int wfs3;
union tu_long_word energy;
union ts_long_word tempenergy;

signed long sumenergy= 0;
signed long maxenergy= 0;

void display_error(void) 
{;}


//====================================================================
/**
  * 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(void)
{
/**
  * First it makes sure that the Embedded Signal Processing is 
  * disabled, otherwise it wouldn't 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= SD16SSEL_1  // Clock selection: SMCLK
  SD16CTL = 0x800 + SD16SSEL_1  // Clock selection: SMCLK + (Amp: )
#if (MCLK_FREQ == 2)
         | SD16DIV_1   // divide by 2 => ADC clock: 1.094MHz
#endif         
#if (MCLK_FREQ == 4)
         | SD16DIV_2   // divide by 4 => ADC clock: 1.094MHz
#endif         
#if (MCLK_FREQ == 8)
         | SD16DIV_3   // divide by 8 => ADC clock: 1.094MHz
#endif         
         | SD16REFON;  // Use internal reference


  SD16CCTL0 = INCH_0;  // I1
  SD16CCTL1 = INCH_0;  // I2
  SD16CCTL2 = INCH_0;  // V

  SD16CONF1 |= 0x40;   // Delay of ADC clock = 40ns
  

// -------------------------------------------------------------------
/** 
  * - Selection of ADC gain:
  *   - VIN,MAX(GAIN = 1) = 0.5V  > VCT(Peak)
  *   - VIN,MAX(GAIN = 2) = 0.25V < VCT(Peak)
  *   - VIN,MAX(GAIN = 16) = 0.031V  > VShunt(Peak)
  *   - VIN,MAX(GAIN = 32) = 0.015V  < VShunt(Peak)
  */
  // -----------------------------------------------------------
  // Configure analog front-end channel 2 - Current 1
   SD16INCTL0= I1_Gain; // Set gain for channel 0 (I1)
//  SD16INCTL0= GAIN_1; // Set gain for channel 0 (I1) to 1
//  SD16INCTL0= GAIN_2; // Set gain for channel 0 (I1) to 2
//  SD16INCTL0= GAIN_32; // Set gain for channel 0 (I1) to 32
  SD16CCTL0 |= OSR_0;  // Set oversampling ratio to 256 (default)

  // -----------------------------------------------------------
  // Configure analog front-end channel 1 - Current 2
  SD16INCTL1= I2_Gain; // Set gain for channel 1 (I2)
//  SD16INCTL1= GAIN_1; // Set gain for channel 1 (I2) to 1
//  SD16INCTL1= GAIN_2; // Set gain for channel 1 (I2) to 2
//  SD16INCTL1= GAIN_16; // Set gain for channel 1 (I2) to 16
  SD16CCTL1 |= OSR_0;  // Set oversampling ratio to 256 (default)

  // -----------------------------------------------------------
  // Configure analog front-end channel 2 - Voltage
  SD16INCTL2= V_Gain; // Set gain for channel 2 (V)
//  SD16INCTL2= GAIN_1; // Set gain for channel 2 (V) to 1
//  SD16INCTL2= GAIN_2; // Set gain for channel 2 (V) to 2
//  SD16INCTL2= GAIN_32; // Set gain for channel 2 (V) to 32
  SD16CCTL2 |= OSR_0;  // Set oversampling ratio to 256 (default)

/**
  * \note 
  * Please note, that the oversampling ratio should be identical 
  * for all channels. Default is 256.
  */       

} // End of init_analog_front_end()

//====================================================================
/**
  * Sets one parameter of the ESP430CE1 module.
  *
  * The parameter \a param is loaded with \a data.
  *
  * \param param Parameter to be set.
  * \param data Data to be loaded into parameter.
  */
void set_parameter(unsigned int param, unsigned int data)
{
  volatile unsigned int timeout= 0xffff;  
  //  /\  Prevend variable from being "optimized".
  MBOUT1= data;
  MBOUT0= param;
  
  do
  { 
    while (((MBCTL & IN0IFG) == 0) && ((--timeout) > 0)) ;
    if (timeout == 0) { display_error(); return; }
  } while ((MBIN0 != mPARAMSET) || (MBIN1 != param));
}

//====================================================================
/**
  * Initializes ESP430CE1.
  *
  */
void init_esp_parameter(unsigned char flashvars)
{
  volatile unsigned int timeout;
  //  /\  Prevend variable from being "optimized".

  // copy predevined init values to RAM
  if (flashvars) s_parameters = s_parameters_flash;
  
/**
  * Makes sure that the Embedded Signal Processing 
  * is enabled, 
  */
  ESPCTL |= ESPEN;
  MBCTL = 0;
    
/**
  * that it is not in measurement or calibration mode,
  */
  if ((RET0 & 0x8000) != 0) 
  { 
    // Set Embedded Signal Processing into "Idle" mode
    MBOUT1= modeIDLE; // ESP_IDLE;
    MBOUT0= mSET_MODE;
    timeout= 0xffff;
    while (((RET0 & 0x8000) != 0) && (timeout-- > 0)) ;
  }

/**
  * and that it is ready to receive messages by requesting the
  * firmware version.
  */
  MBOUT0= mSWVERSION;
  timeout= 0xffff;
  do
  { 
    while (((MBCTL & IN0IFG) == 0) && (timeout-- > 0)) ;
    if (timeout == 0) { display_error(); return; }
  } while (MBIN0 != mSWRDY);
  firmware_version= MBIN1; // Save firmware version.
  
/**
  * Then the parameters are initialized.
  *
  * \par Control 0: make settings for :
  * - Use current channel I2 - tamper-detection
  * - Count absolute active energy 
  *   (negative energy is considered as tampering)
  * - Switch DC removal alorithm on for I1
  * - Switch DC removal alorithm on for I2
  */
  set_parameter(mSET_CTRL0, defSET_CTRL0);

/**
  * \Set Number of Measurement: 
  *    e.g.  4096 * 50Hz. => int after 1sec
  */
  set_parameter(mSET_INTRPTLEVL_LO, s_parameters.pSET_INTRPTLEVL.w[0]);
  set_parameter(mSET_INTRPTLEVL_HI, s_parameters.pSET_INTRPTLEVL.w[1]);


/**
  * \par Nominal Mains Frequency: 
  *    e.g.  50Hz.
  */
  set_parameter(mSET_NOMFREQ, defSET_NOMFREQ);
  
/**
  * \par Phase Error Correction:
  * Sets phase error for current 1/2 at nominal mains frequency for 
  * current transformer according to its specification
  * The phase error of the shunt is zero.
  */
  set_parameter(mSET_PHASECORR1, (int)s_parameters.pSET_PHASECORR1);
  set_parameter(mSET_PHASECORR2, (int)s_parameters.pSET_PHASECORR2);
  
/** \par Adjustment parameters for the two currents:
  * Current Transformer:
  * \par
  * There are two possibilties to adjust the two current
  * values:
  * -# Only one current value is scaled with a factor > 1
  *    to fit the others current's value. The factor
  *    for the later is set to 1.\n
  *    In this example current I1 would be scaled by 0.32/0.30 = 1.06667.
  *    (The RMS values at the maximum current are used to calculate the
  *     factor.)
  *    The current transformer's value is scaled to fit with 
  *    shunt's value, because the shunt's values are bigger, 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产福利一区二区| 久久99蜜桃精品| 91精品福利在线| 一区二区三区在线观看网站| 色呦呦国产精品| 亚洲高清在线精品| 91.com在线观看| 加勒比av一区二区| 国产精品毛片大码女人| 色噜噜狠狠成人网p站| 亚洲成av人片在www色猫咪| 欧美日韩mp4| 国产美女视频91| 亚洲欧洲精品一区二区三区| 欧美午夜在线一二页| 日本亚洲最大的色成网站www| 久久伊99综合婷婷久久伊| 成人性生交大合| 亚洲成a人v欧美综合天堂下载| 欧美成人一区二区三区在线观看| 国产精品一区二区你懂的| 亚洲人成在线播放网站岛国| 91精品婷婷国产综合久久竹菊| 国产精品一区二区三区网站| 亚洲乱码国产乱码精品精可以看| 欧美精品第一页| 国产伦理精品不卡| 亚洲一级片在线观看| 欧美mv日韩mv亚洲| 色综合网色综合| 裸体健美xxxx欧美裸体表演| 国产精品激情偷乱一区二区∴| 欧美日韩日日骚| 国产99久久久国产精品免费看| 亚洲午夜视频在线| 中文在线一区二区| 日韩三级在线观看| 色综合中文字幕国产 | 日韩情涩欧美日韩视频| 豆国产96在线|亚洲| 日韩成人免费在线| 悠悠色在线精品| 国产欧美日韩另类一区| 91精品国产手机| 色综合中文字幕| 粉嫩av一区二区三区在线播放 | 精品国产一二三区| 欧美性一二三区| 91免费版在线| 国产精品一线二线三线精华| 秋霞午夜av一区二区三区| 亚洲免费三区一区二区| 欧美韩日一区二区三区| 精品日韩一区二区| 欧美色视频在线| 色综合天天综合色综合av | 视频在线观看91| 亚洲精品你懂的| 国产精品初高中害羞小美女文| 久久综合久久鬼色中文字| 欧美高清视频www夜色资源网| 91蜜桃视频在线| 成人免费视频视频在线观看免费| 久久国产福利国产秒拍| 日本91福利区| 免费成人在线观看视频| 亚洲电影一区二区| 亚洲天堂a在线| 中日韩免费视频中文字幕| 欧美激情艳妇裸体舞| 国产午夜亚洲精品理论片色戒| 久久日一线二线三线suv| 精品奇米国产一区二区三区| 精品日韩一区二区| 精品国产乱码久久久久久1区2区| 日韩精品一区二区三区在线观看| 69av一区二区三区| 欧美大胆人体bbbb| 久久婷婷综合激情| 久久这里只精品最新地址| 久久久久综合网| 国产精品天天看| 综合久久久久久| 亚洲精品乱码久久久久久久久| 一区二区三区四区蜜桃| 亚洲v中文字幕| 奇米精品一区二区三区四区 | 在线亚洲一区二区| 欧美片在线播放| 欧美一区在线视频| 亚洲制服丝袜在线| 亚洲国产日日夜夜| 日韩av网站在线观看| 亚洲丶国产丶欧美一区二区三区| 中文字幕中文字幕在线一区| 亚洲日韩欧美一区二区在线| 国产欧美日韩久久| 亚洲乱码国产乱码精品精98午夜| 亚洲国产精品一区二区久久恐怖片 | 亚洲欧美另类久久久精品| 一区二区在线观看av| 午夜欧美在线一二页| 久久精品国产秦先生| 成人美女视频在线观看18| 91国偷自产一区二区三区观看| 欧美精品一二三四| 久久这里只有精品6| 亚洲美女视频在线观看| 日韩精品电影在线观看| 国产91在线|亚洲| 91福利资源站| 久久先锋影音av| 一区二区三区毛片| 韩日av一区二区| 色乱码一区二区三区88 | 国产亚洲一二三区| 亚洲一级二级三级在线免费观看| 美女一区二区久久| 91亚洲国产成人精品一区二三| 制服丝袜亚洲精品中文字幕| 中文一区一区三区高中清不卡| 香蕉久久一区二区不卡无毒影院 | 日韩亚洲欧美一区二区三区| 欧美激情综合在线| 天堂成人免费av电影一区| 成人高清免费观看| 日韩一级免费观看| 亚洲综合免费观看高清完整版| 国产精品一二三区在线| 欧美日韩精品三区| 国产精品不卡视频| 国产一区在线观看视频| 精品视频一区二区三区免费| 国产亚洲va综合人人澡精品| 日本欧美肥老太交大片| 91网站黄www| 国产亚洲欧洲997久久综合| 天堂蜜桃一区二区三区 | 日韩综合小视频| 色综合天天综合狠狠| 亚洲精品在线免费播放| 视频一区二区欧美| 91久久精品一区二区| 亚洲国产高清在线观看视频| 激情综合色综合久久| 日韩欧美国产一区二区在线播放| 一区二区三区 在线观看视频| 高清不卡在线观看av| 精品处破学生在线二十三| 婷婷久久综合九色综合伊人色| 色综合一个色综合| 综合久久国产九一剧情麻豆| 岛国一区二区三区| 久久香蕉国产线看观看99| 美国av一区二区| 欧美精品久久久久久久久老牛影院| 一区二区三区资源| 91亚洲精华国产精华精华液| 亚洲欧洲av在线| av电影在线不卡| 中文字幕在线免费不卡| av亚洲精华国产精华| 亚洲国产激情av| 国产黑丝在线一区二区三区| 国产视频在线观看一区二区三区| 精品一区二区三区免费毛片爱| 欧美一二区视频| 日本中文字幕一区二区有限公司| 欧美日韩精品欧美日韩精品一| 亚洲一区二区三区小说| 欧美手机在线视频| 亚洲bt欧美bt精品777| 欧美三级电影网站| 午夜精品视频在线观看| 91精品国产综合久久香蕉麻豆| 天天色 色综合| 日韩片之四级片| 国产一区二区成人久久免费影院| 2021国产精品久久精品| 国产精品自拍一区| 国产欧美一区二区在线| www.一区二区| 亚洲综合丝袜美腿| 在线综合+亚洲+欧美中文字幕| 视频一区在线播放| 精品国产乱码久久久久久图片| 国产精品白丝jk黑袜喷水| 国产欧美日本一区二区三区| 99re在线精品| 丝袜亚洲另类丝袜在线| 精品久久久久av影院| 国产精品一级在线| 亚洲欧洲日韩在线| 欧美亚洲动漫精品| 国产麻豆精品95视频| 欧美国产精品一区二区三区| 欧美在线免费观看亚洲| 日本va欧美va欧美va精品| 国产欧美一区在线| 欧美三级韩国三级日本一级|