• 大小: 78KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-18
  • 语言: 其他
  • 标签: 电动车窗  

资源简介

4窗防夹电动车窗控制。含原理图。非常不错的参考实例,软件硬件设计者的典范。

资源截图

代码片段和文件信息

#ifndef _DIS_C_
#define _DIS_C_

#include “global.h“

void fEnDistinguishDriverMotorType(void)
{

rEnTimer2 |= bEnTimer2ForDM; 
rTimer2CounterForDM = 0x3f;

if(~rEnTimer2 & bEnTimer2 )
{
fInitialTimer2();
TMR2ON = 1; //start to increment.
rEnTimer2 |= bEnTimer2;
}

}


void fInitialTimer2(void)
{
T2CON = 0;   //stop timer2
  TMR2 = 0; //clear timer2 register
PR2 = TMR2 + 125; // 1ms
PEIE = 1;
TMR2IE = 1;
TMR2IF = 0;
  T2CKPS1 = 1; //prescale  1/16
}

void fTimer2InterruptSeviceRoutine(void)
{
PR2 = TMR2 + 125; // 1ms
bHavePassed1ms = 1;
TMR2IF = 0; // Clr interrupt flag ready for next
}


void fTimer2ISR(void)
{
if(bHavePassed1ms)
{
bHavePassed1ms = 0;


if( rEnTimer2 & bEnTimer2ForDM)
fDisDriverMotorType();
/*
if(rEnDisLoadType & bEnDisFrontMotor)
fDisFrontMotorType();

if(rEnDisLoadType & bEnDisRearLeftMotor)
fDisRearLeftMotorType();

if(rEnDisLoadType & bEnDisRearRightMotor)
fDisRearRightMotorType();
*/


if( ~rEnTimer2 & ( bEnTimer2ForDM + bEnTimer2ForFM 
+ bEnTimer2ForLM + bEnTimer2ForRM ))
{
TMR2ON = 0;
rEnTimer2 &= ~bEnTimer2;
}
}
}




void fDisDriverMotorType(void)
{
unsigned char vADResult;

unsigned char vStep;
unsigned char vTimer;
unsigned char vAddress;

unsigned int vValue;
unsigned char vPeak;
unsigned char vMean;
/*
+--------------------+----+----+----+----+----+----+----+----+
|rTimer2CounterForDM |   Step  | BufferAddress| TimerCounter |   
+--------------------+----+----+----+----+----+----+----+----+
*/

vStep = rTimer2CounterForDM >> 6;
vTimer = rTimer2CounterForDM & 0x07;
vAddress = rTimer2CounterForDM & 0b00111000; 
vAddress >>= 3;

if( vStep == mStepNoAction)
{
if(vTimer)
{
fItlADC();
vADResult = fADConverter(AD_DrM);


if( vADResult > mThreshold)
{
rBufferForDM[vAddress] = vADResult;

vStep = mStepRise;
rTimer2CounterForDM = 0x37 ;  //vAddress = 6;
rTimer2CounterForDM |=  vStep << 6;
}

rTimer2CounterForDM--;
}

else //if the value all < threshold continuiously.
{

;
;
;
;
;
;
}
}


if( vStep ==  mStepRise)
{
fItlADC();
vADResult = fADConverter(AD_DrM);

rBufferForDM[vAddress] = vADResult;

if(vAddress)
{
rTimer2CounterForDM -= 0x8; //vaddress - 1; 
    }
else
{
vValue = fGetAverageAndMaxFromBuffer(rBufferForDM);
vPeak = vValue;
vMean = vValue >> 8;
// add code


vStep = mStepFall;
rTimer2CounterForDM &= 0x3f ; //vAddress = 7;vTimer = 7;
rTimer2CounterForDM |=  vStep << 6;
}
}

if( vStep ==  mStepFall)
{
if(vTimer)
{
vTimer--;

}
else
{
fItlADC();
vADResult = fADConverter(AD_DrM);
rBufferForDM[vAddress] = vADResult;

if(vAddress)
{
vAddress--;
vAddress = 0x07 <<

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      70764  2007-05-16 08:28  powerwindow\4965001 200705 schematic.pdf

     文件       3061  2007-06-06 08:09  powerwindow\configuration.h

     文件       4147  2007-06-07 11:54  powerwindow\distinguish.c

     文件       3070  2007-06-06 08:43  powerwindow\distinguish.h

     文件        284  2007-06-04 09:05  powerwindow\global.h

     文件       2432  2007-05-29 16:52  powerwindow\initial.c

     文件        482  2007-04-09 10:50  powerwindow\initial.h

     文件        951  2007-06-06 09:02  powerwindow\interrupt.c

     文件        236  2007-06-04 08:48  powerwindow\Interrupt.h

     文件      22723  2007-06-04 09:07  powerwindow\key.c

     文件       5599  2007-06-06 08:56  powerwindow\key.h

     文件        737  2007-06-08 14:19  powerwindow\main.c

     文件       1027  2007-06-06 08:51  powerwindow\main.h

     文件       4075  2007-05-25 13:44  powerwindow\motor.c

     文件       2313  2007-06-06 08:47  powerwindow\motor.h

     文件        791  2007-05-23 11:34  powerwindow\portb.c

     文件        389  2007-06-04 09:03  powerwindow\portb.h

     文件       1860  2007-05-23 16:23  powerwindow\rtos.c

     文件        458  2007-06-06 08:45  powerwindow\rtos.h

     文件       2133  2007-06-06 08:16  powerwindow\typedef.h

     目录          0  2009-02-25 19:51  powerwindow

----------- ---------  ---------- -----  ----

               127750                    22


评论

共有 条评论

相关资源