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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? psoft.c

?? TDK 6521 SOC 芯片 DEMO程序
?? C
字號(hào):
/***************************************************************************
 * This code and information is provided "as is" without warranty of any   *
 * kind, either expressed or implied, including but not limited to the     *
 * implied warranties of merchantability and/or fitness for a particular   *
 * purpose.                                                                *
 *                                                                         *
 * Copyright (C) 2005 Teridian Semiconductor Corp. All Rights Reserved.    *
 ***************************************************************************/
//**************************************************************************
//  DESCRIPTION: 71M65xx POWER METER - Software pulsing.
//  This code emits pulses on two DIO pins, PULSE3 and PULSE4, proportional
//  to power inputs on the psoft_update() interface.  Rename the DIO
//  pins PULSE3 and PULSE4 in reg65xx.h to move the outputs to different pins.
//  The pins for PULSE3 and PULSE4 have to be initialized in defaults.c.
//  It uses the same units and interface as the CE pulse outputs,
//  except implemented in software on the MPU.
//  It generates 50% duty-cycle pulses, and is linear (within 0.0001%) from 
//  150Hz to below 0.01 Hz, giving at least four decades of accuracy.
//  Jitter is about 3.2 ms.
//  It is preintegrated with the version 4 demo firmware, and
//  can optionally count its pulses (See pcnt.c for more info on pulse counts).
// 
//  AUTHOR:  RGV
//
//  HISTORY: See end of file.
//**************************************************************************
//  File: psoft.c
//               
#include "options.h"
#if PULSE_SOFT
#include "library.h"
#include "psoft.h"

/*** Public variables declared within this module *** Selectable via "defaults" */
bool pulse3_val;
bool pulse4_val;
volatile int32i_t pulse3_accum;
volatile int32i_t pulse4_accum;
volatile int32i_t pulse3_inc;
volatile int32i_t pulse4_inc;

#if PULSE_CNT
uint16d_t dPulse3_Cnt, dPulse4_Cnt;
#endif

/*** Private functions declared within this module ***/
#pragma save
#pragma NOAREGS
// This routine can be called in the ce_busy interrupt, 2520/8 times
// per second, and from there it will use about 3% of the total CPU
// in real time.  The hardware and software timers have too much jitter 
// to run this routine and generate a stable pulse output.
// When run from the CE busy interrupt, the pulse outputs appear synchronized
// to the CE pulse outputs, even though they are simply done at the same
// frequency.
void psoft_out(void) small reentrant
{
    // calculates pulse value without using I/O, in order to
    // increase noise resistance
    pulse3_accum += pulse3_inc;
    if (pulse3_val != (pulse3_accum < 0)) // did bit 31 change?
    {
        // It has to change.
        // If it's at the starting value, count it
        #if PULSE_CNT
	    if (pulse3_val)
        {
            ++dPulse3_Cnt; // count the pulse outputs
            // This count needs to be added to a longer, 64 bit
            // count once per second.  See pcnt.c
        }
        #endif
        pulse3_val = ~pulse3_val;
        PULSE3 = pulse3_val; // set a DIO configured for output
    }

    // calculates pulse value without using I/O, in order to
    // increase noise resistance
    pulse4_accum += pulse4_inc;
    if (pulse4_val != (pulse4_accum < 0)) // did bit 31 change?
    {
        // It has to change.
        // If it's at the starting value, count it
        #if PULSE_CNT
        if (pulse4_val)
        {
            ++dPulse4_Cnt; // count the pulse outputs
            // This count needs to be added to a longer, 64 bit
            // count once per second.  See pcnt.c
        }
        #endif
        pulse4_val ^= 1;
        PULSE4 = pulse4_val; // set a DIO configured for output
    }
}
#pragma restore


// the inputs are watt hours, as generated by the CE, and set the pulse 
// generators to blink at the same rate as CE pulse outputs, with the same 
// units.  This should be called each time a new accumulation interval has data.
void psoft_update (int32_t pulse3_in, int32_t pulse4_in)
{
    bool ea_saved;
    bool PulseFast, PulseSlow; 
    int32_t xdata Wrate;
    #if M6520
    uint32_t my_cestate;
    #endif

    // figure software pulse outputs pulse 3 and 4
    // The designed maximum frequency is 157.54 Hz,
    // somewhat over a practical 150 Hz spec.
    // The CE code has a pulse rate 3x2520Hz, 
    // the CE_BUSY interrupt skips 7, a 1/8 decimation of 2520 Hz.k
    #if M6520
    my_cestate = memget_ce(&cestate);
    PulseFast = (0 != (my_cestate & CE_PULSE_FAST));
    PulseSlow = (0 != (my_cestate & CE_PULSE_SLOW));
    #elif TRACE10
    PulseFast = (memget_ce (&pulse_fast) < 0) ? 0 : 1;
    PulseSlow = (memget_ce (&pulse_slow) < 0) ? 0 : 1;
    #elif HOST15
    PulseFast = pulse_fast;
    PulseSlow = pulse_slow;
    #else
    #error unknown device type
    #endif

    Wrate = memget_ce (&wrate);
    pulse3_in = 3 * pulse3_in;
    pulse4_in = 3 * pulse4_in;

    if (!PulseSlow)
    {
        if (!PulseFast)
        {
            // simulated at 0.0001% error
            pulse3_in = ((pulse3_in + 512L) >> 10) * Wrate;
            pulse4_in = ((pulse4_in + 512L) >> 10) * Wrate;
        }
        else
        {
            // simulated at 0% (too small to print) error
            // This case fails for speeds even slightly faster than 150 Hz
            pulse3_in = ((pulse3_in + 32L) >> 6) * Wrate;
            pulse4_in = ((pulse4_in + 32L) >> 6) * Wrate;
        }
    }
    else
    {
        if (!PulseFast)
        {
            // simulated at 0.00006% error
            // The 2^16 divisor causes 0.005% error by
            // underflow unless the division is performed in two steps
            pulse3_in = ((pulse3_in + 512L) >> 10) * Wrate;
            pulse3_in = (pulse3_in + 32L) >> 6;
            pulse4_in = ((pulse4_in + 512L) >> 10) * Wrate;
            pulse4_in = (pulse4_in + 32L) >> 6;
        }
        else
        {
            // simulated at 0.0001% error
            pulse3_in = ((pulse3_in + 2048L) >> 12) * Wrate;
            pulse4_in = ((pulse4_in + 2048L) >> 12) * Wrate;
        }
    }
    ea_saved = EA;
    EA = 0;
    pulse3_val = PULSE3; // update the pulse value
    pulse4_val = PULSE4;
    pulse3_inc = pulse3_in;
    pulse4_inc = pulse4_in;
    EA = ea_saved;
}

// Initialize the software pulse outputs
void psoft_init(void)
{
    // the DIO for pulse3 and 4 should be configured in defaults
    // for the starting values and direction
    // start with pulse outputs high (bit 31 is put out)
    pulse3_inc = 0;
    pulse3_val = PULSE3; // set the starting polarity for the pulse
    if (pulse3_val)
        pulse3_accum = 0xC0000000;
    else
        pulse3_accum = 0x40000000;

    pulse4_inc = 0;
    pulse4_val = PULSE4; // set the starting polarity for the pulse
    if (pulse4_val)
        pulse4_accum = 0xC0000000;
    else
        pulse4_accum = 0x40000000;

    #if M6520 // pulse3 and pulse4 are the same pins as OPT_RX and OPT_TX
    DIO |= OPT_RXDIS;  // disable OPT_RX, enable DIO1 = PULSE3
    // Config2 is also affected by ser1.h, which contains code
    // to switch between an optical serial port, and optical pulse.
    // It does this automatically, by the way, if the command line interface
    // is in the system.  See ser1cli.c for the high level code.
    CONFIG2 = (CONFIG2 & !OPT_TXE) | _DIO2;  // disable OPT_RX, enable DIO2/P4
    #endif
}

#endif // PULSE_SOFT
/***************************************************************************
 * History:
 * $Log: psoft.c,v $
 * Revision 1.15  2006/10/13 00:51:11  tvander
 * Removed compile options for 6530, 6515;
 * renamed 6511 and 6513 to trace11 and trace13;
 * Binary verified unchanged from previous version.
 *
 * Revision 1.14  2006/09/09 01:14:40  gmikef
 * *** empty log message ***
 *
 * Revision 1.13  2006/08/17 22:18:20  tvander
 * Tested with 6513 and 6521F at 4.9mHz.  Fails with 6521F at 614kHz.
 *
 * Revision 1.12  2006/08/08 18:46:13  tvander
 * Added an option for 6515 test PCB
 *
 * Revision 1.11  2006/03/03 11:30:38  Michael T. Fischer
 * Prep for 6530 LCD, etc.
 *
 * Revision 1.10  2006/01/16 20:11:29  tvander
 * Clean Keil build, all versions
 *
 * Revision 1.9  2006/01/04 04:47:54  gmikef
 * Switched RMS and VA calculations to use floating point. (and Calibration).
 *
 * Revision 1.7  2005/12/21 01:35:28  tvander
 * 6513
 *
 * Revision 1.6  2005/09/22 23:45:19  tvander
 * Clean build all models and unit tests, updated copyright to be fore Teridian
 *
 * Revision 1.5  2005/09/12 07:47:31  tvander
 * Power measurement is stable, with no creep.
 * VARh measurement is stable, with no creep.
 * Pulse sources work.
 * Full access to MPU variables.
 * Rolled date.
 * Clock software works.
 *
 * Revision 1.4  2005/08/30 18:19:46  gmikef
 * *** empty log message ***
 *
 * Revision 1.3  2005/08/12 21:56:26  tvander
 * Fixed logic error is flag decoding.
 *
 * Revision 1.2  2005/08/12 06:02:47  gmikef
 * Added MPU temperature compensation for GAIN_ADJ.
 * Added changes to support new CE 6521 code.
 *
 * Revision 1.1  2005/08/02 22:36:30  tvander
 * Optional software pulse logic.
 * Fixed build in 6511B and 6521B
 *
 * Copyright (C) 2005 Teridian Semiconductor Corp. All Rights Reserved.    *
 * this program is fully protected by the United States copyright          *
 * laws and is the property of Teridian Semiconductor Corporation.         *
 ***************************************************************************/

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产调教视频一区| 亚洲电影第三页| 亚洲不卡一区二区三区| 蜜臀av性久久久久蜜臀av麻豆| 成人午夜伦理影院| 91精品国产91久久久久久一区二区| 国产精品妹子av| 国产原创一区二区| 色综合久久中文综合久久牛| 精品国免费一区二区三区| 亚洲精品国产精品乱码不99| 国产精品123区| 亚洲精品在线一区二区| 五月激情六月综合| 91免费在线视频观看| 中文字幕精品在线不卡| 日韩av一区二| 欧美精品在线观看一区二区| 精品国产免费久久 | 久久久亚洲精品石原莉奈| 一区二区在线免费| 成人激情动漫在线观看| 久久精品夜色噜噜亚洲aⅴ| 久久99精品久久久久婷婷| 欧美裸体一区二区三区| 亚洲电影在线免费观看| 91传媒视频在线播放| 亚洲视频免费看| 91美女视频网站| 日韩一区中文字幕| 99国产精品国产精品毛片| 国产精品视频yy9299一区| 国产激情一区二区三区四区| 国产无人区一区二区三区| 国产在线精品免费| 国产蜜臀97一区二区三区| 国产91在线观看丝袜| 中文字幕精品三区| 波多野结衣亚洲一区| 国产精品美女久久久久久久久久久| 国内精品久久久久影院薰衣草| 亚洲精品在线观| 国产a久久麻豆| 亚洲视频一区二区在线观看| 色婷婷av一区二区三区之一色屋| 亚洲美腿欧美偷拍| 欧美日韩中字一区| 蜜桃av一区二区在线观看| 日韩一区二区三区在线视频| 国产一区二区三区久久久| 久久久久久久久岛国免费| 成人永久看片免费视频天堂| 最近日韩中文字幕| 欧美日韩一区国产| 麻豆成人久久精品二区三区红| 精品处破学生在线二十三| 成人免费高清在线| 亚洲与欧洲av电影| 欧美va亚洲va在线观看蝴蝶网| 国产夫妻精品视频| 一区二区三区日韩欧美精品| 欧美日韩亚洲综合在线 | 国产一区二区福利| 中文天堂在线一区| 日韩一区二区高清| 激情五月婷婷综合| 国产精品久久久久影院| 欧美性受xxxx| 国产在线播放一区三区四| 一区二区在线免费观看| 欧美www视频| 色欧美88888久久久久久影院| 性久久久久久久久| 国产亚洲精品aa| 欧美日韩情趣电影| 粉嫩一区二区三区在线看| 一区二区三区在线视频播放| 精品欧美乱码久久久久久 | 亚洲欧美日韩在线| 欧美一区日韩一区| www.欧美.com| 精品一区二区三区免费观看| 亚洲码国产岛国毛片在线| 日韩精品一区二区三区视频| 色综合久久88色综合天天6| 久久66热re国产| 亚洲成av人片在线观看| 一区二区中文视频| 久久免费视频色| 欧美一区二区黄| 91久久奴性调教| fc2成人免费人成在线观看播放 | 亚洲综合一区在线| 久久精品日韩一区二区三区| 欧美日韩精品一区二区天天拍小说| 播五月开心婷婷综合| 久久99精品久久只有精品| 亚洲成人av一区二区三区| 国产精品久久久久aaaa樱花| 精品国产一二三区| 欧美一区二区三区男人的天堂| 欧美亚洲动漫精品| 91在线播放网址| 国产91在线看| 国产精品夜夜嗨| 久久草av在线| 亚洲va欧美va人人爽| 亚洲图片欧美一区| 亚洲精品久久久久久国产精华液| 中文字幕欧美激情| 亚洲国产精华液网站w| 久久久精品影视| 久久女同性恋中文字幕| 精品国产凹凸成av人网站| 欧美一卡在线观看| 91精品久久久久久久91蜜桃| 3atv一区二区三区| 欧美日韩高清影院| 制服.丝袜.亚洲.中文.综合| 欧美伦理视频网站| 欧美一区二区三区在线电影| 日韩午夜电影在线观看| 欧美成人精品福利| 精品国产伦一区二区三区免费| 日韩精品综合一本久道在线视频| 欧美不卡123| 国产欧美日韩激情| 国产精品毛片a∨一区二区三区| 中文字幕av不卡| 亚洲嫩草精品久久| 亚洲已满18点击进入久久| 亚洲尤物视频在线| 亚洲va在线va天堂| 美女网站一区二区| 色综合久久综合网欧美综合网| 91色婷婷久久久久合中文| 91久久一区二区| 91精品国产色综合久久ai换脸 | 国产精品久久久久久福利一牛影视| 日本一区二区高清| 一区二区在线观看不卡| 亚洲成人av在线电影| 狠狠色狠狠色合久久伊人| jlzzjlzz亚洲女人18| 欧美性色黄大片| 精品国产1区2区3区| 中文字幕第一区综合| 亚洲美女少妇撒尿| 蜜桃视频第一区免费观看| 国产一区二区三区不卡在线观看| 不卡av免费在线观看| 欧美酷刑日本凌虐凌虐| 国产午夜精品在线观看| 亚洲免费视频中文字幕| 同产精品九九九| 成人网男人的天堂| 在线不卡a资源高清| 国产农村妇女毛片精品久久麻豆| 亚洲在线成人精品| 国产九九视频一区二区三区| 色欧美乱欧美15图片| www欧美成人18+| 亚洲国产欧美在线人成| 国产在线播放一区三区四| 在线免费观看不卡av| 久久久久国色av免费看影院| 亚洲图片欧美视频| 成人综合日日夜夜| 精品久久人人做人人爱| 一卡二卡三卡日韩欧美| 国产专区欧美精品| 欧美精品在线一区二区三区| 国产精品福利电影一区二区三区四区 | 欧美sm极限捆绑bd| 亚洲精品中文在线| 国产不卡在线视频| 精品国产一区二区三区忘忧草 | 久久色在线观看| 天堂成人免费av电影一区| bt欧美亚洲午夜电影天堂| ww亚洲ww在线观看国产| 免费成人在线播放| 欧美电影一区二区| 亚洲国产精品一区二区www| 成人黄色在线网站| 国产人成亚洲第一网站在线播放| 久久国产精品99久久人人澡| 欧美午夜视频网站| 亚洲电影一级黄| 精品视频一区三区九区| 亚洲三级小视频| 99国内精品久久| 亚洲男女一区二区三区| 菠萝蜜视频在线观看一区| 中文字幕免费在线观看视频一区| 国产高清无密码一区二区三区| 精品日韩在线一区| 精品中文字幕一区二区| 国产91精品一区二区麻豆亚洲| 色婷婷综合久久久|