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

📄 etpuc_ppa.c

📁 mpc55**系列芯片的例程 包括SCI,SPI,TIMER,FIT,EDMA等几乎所有功能的实现
💻 C
📖 第 1 页 / 共 4 页
字号:
	             {
			  			 /*--------------------------------------------------------------------------+
							 | STATE NAME: TRANS5                                                        |
						 	 | Conditions under which this state is executed:-                           |
						 	 |   Measurement = Inactive                                                  |
						 	 |   LastPin = Low                                                           |
						 	 |   Transition occurred                                                     |
							 |   Mode is High  pulse measurement                                         |
							 |   Channel.PSS is 1                                                        |
							 |Start normal high measurement                                              |
							 |Record erta in LastTime                                                    |
      		 	   |Clear match flagA                                                          |
							 |Schedule a match SampleTime in the future                                  |
							 |Set Measurement to Active                                                  |
							 |                                                                           |
							 +--------------------------------------------------------------------------*/

	                Read1Retrig();
	                Measurement = Active;
	             }
	             else	/* a glitch occurred */
	             {
			  			 /*--------------------------------------------------------------------------+
							 | STATE NAME: TRANS6                                                        |
						   | Conditions under which this state is executed:-                           |
					     |   Measurement = Inactive                                                  |
						   |   LastPin = Low                                                           |
						   |   Transition occurred                                                     |
						   |   Mode is High pulse measurement                                          |
						   |   Channel.PSS is 0                                                        |
						   |i.e. a short positive pulse occurred                                       |
						   |Add short pulse width to Accum                                             |
      		 	   |Clear match flagA                                                          |
						   |Schedule a match SampleTime in the future                                  |
						   |If sufficient HighPulses have been accumulated update Result with Accum    |
						   |  and Status takes the value of StatAcc; StatAcc get set to 0              |
						   |Measurement remains Inactive                                               |
						   |                                                                           |
							 +--------------------------------------------------------------------------*/

	                MeasGlitch();	/* read both capture registers */
	                CheckCount();	/* Retain inactive state */
	             }
	          }
	          else	/* Low pulse measurement */
	          {
	             if (SampledInputPin == 0)	/* Glitched start of low measurement */
	             {
			  			 /*--------------------------------------------------------------------------+
							 | STATE NAME: TRANS7                                                        |
						   | Conditions under which this state is executed:-                           |
						   |   Measurement = Inactive                                                  |
						   |   LastPin = Low                                                           |
						   |   Transition occurred                                                     |
						   |   Mode is Low pulse measurement                                           |
						   |   Channel.PSS is 0                                                        |
						   |i.e. a glitch occurred at the start of a low pulse measurement             |
						   |Record ertb in LastTime                                                    |
      		 	   |Clear match flagA                                                          |
  					   |Schedule a match SampleTime in the future                                  |
						   |Set Measurement to Active                                                  |
						   |                                                                           |
						   +--------------------------------------------------------------------------*/
	                Read2Retrig(); /* Start low measurement on second capture edge */
	                Measurement = Active;
	             }
			  			 /*--------------------------------------------------------------------------+
							 | STATE NAME: TRANS8                                                        |
						   | Conditions under which this state is executed:-                           |
							 |   Measurement = Inactive                                                  |
							 |   LastPin = Low                                                           |
							 |   Transition occurred                                                     |
							 |   Mode is Low pulse measurement                                           |
							 |   Channel.PSS is 1                                                        |
							 |i.e. The first edge was rising                                             |
							 |Do nothing; wait for next edge                                             |
							 +--------------------------------------------------------------------------*/
	             else             /* First edge goes high, so wait for next edge */
	             {}               /* Do_Nothing */
	          }
	       }
	       else                   /* It's a period measurement */
	       {
			   /*--------------------------------------------------------------------------+
				 | STATE NAME: TRANS9                                                        |
				 | Conditions under which this state is executed:-                           |
				 |   Measurement = Inactive                                                  |
				 |   LastPin = Low                                                           |
				 |   Transition occurred                                                     |
				 |   Mode is Period measurement                                              |
				 |i.e. Start of period measurment                                            |
				 |Clear transition detect latch                                              |
				 |Record erta in LastTime                                                    |
         |Clear match flagA                                                          |
				 |Schedule a match SampleTime in the future                                  |
				 |Set Measurement to Active                                                  |
				 |                                                                           |
				 +--------------------------------------------------------------------------*/

            ClearTransLatch();
	          Read1Retrig();
	          Measurement = Active;
	       } /* end period measurement */
	    }     /* end Transition_A */
	    else /* It's an invalid match */
	    {
			/*--------------------------------------------------------------------------+
			| STATE NAME: MATCH2                                                        |
			| Conditions under which this state is executed:-                           |
			|   Measurement = Inactive                                                  |
			|   LastPin = Low                                                           |
			|   Match occurred                                                          |
			|This is an invalid match condition                                         |
			|Clear match flag A                                                     |
			|                                                                           |
			+--------------------------------------------------------------------------*/

	        ClearMatchALatch();
	    }
    }    /* end Measurement inactive service request, LastPin low */
/*--------------------------------------------------------------------------+
| THREAD NAME: THREAD5                                                      |
| DESCRIPTION:                                                              |
| Measurement active service request, LastPin low                           |
| If entered due to a transition; then:                                     |
| 	If doing pulse measurement                                              |
| 		Latch the pin state and clear transition detect latch                 |
|   	Set LastPin to the sample pin state                                   |
|   	Execute state TRANS10 or TRANS11 or TRANS12 dependant upon            |
|   	  PulseMeasurement/PinSampledState                                    |
|		Else doing period measurement                                           |
|   	Execute state TRANS13                                                 |
| Else must have been entered due to a match; then                          |
|   Execute state MATCH3                                                    |
|                                                                           |
+--------------------------------------------------------------------------*/
  else if (((Measurement==Active) && (LastPin==Low) && m1) ||
   			   ((Measurement==Active) && (LastPin==Low) && m2))
      {
          if (Transition_A)
          {
              if (PulseMeasurement)
              {
                 CheckPin();
                 Assign(LastPin,SampledInputPin);    /* update Last_Pin state */
                 if (LowPulse)
                 {
                    if (SampledInputPin == 1)        /* Stop normal low measurement */
                    {
								    /*--------------------------------------------------------------------------+
									  | STATE NAME: TRANS10                                                       |
						   			| Conditions under which this state is executed:-                           |
							 			|   Measurement = active                                                    |
							 			|   LastPin = Low                                                           |
							 			|   Transition occurred                                                     |
							 			|   Mode is Low pulse measurement                                           |
							 			|   Channel.PSS is 1                                                        |
							 			|Stop Normal Low Pulse Measurement                                          |
										|Add TCRs elapsed between this event and the previous event to Accum        |
										|If Accum overflows send a Channel Interrupt and DMA Request                |
						   			|If sufficient Periods have been accumulated update Result with Accum       |
						   			|  and Status takes the value of StatAcc; StatAcc get set to 0              |
						   			|Measurement set to Inactive                                                |
										|                                                                           |
									  +--------------------------------------------------------------------------*/

                       AccumTime();
                       CheckCount();     /* Update measurement if all done */
                       Measurement = Inactive;
                    }
                    else	           /* A narrow positive pulse occurred */
                    {
								    /*--------------------------------------------------------------------------+
									  | STATE NAME: TRANS11                                                       |
						   			| Conditions under which this state is executed:-                           |
							 			|   Measurement = active                                                    |
							 			|   LastPin = Low                                                           |
							 			|   Transition occurred                                                     |
							 			|   Mode is Low pulse measurement                                           |
							 			|   Channel.PSS is 0                                                        |
							 			|A narrow positive pulse occurred                                           |
										|Add TCRs elapsed between this event and the previous event to Accum        |
										|If Accum overflows send a Channel Interrupt and DMA Request                |
						   			|Record ertb in LastTime                                                    |
            		 	  |Clear match flagA                                                          |
						   			|Schedule a match SampleTime in the future                                  |
						   			|If sufficient Periods have been accumulated update Result with Accum       |
						   			|  and Status takes the value of StatAcc; StatAcc get set to 0              |
						   			|Measurement remains Active                                                 |
										|                                                                           |
										+--------------------------------------------------------------------------*/

                       AccumTime();      /* Accumulate time to rising edge, */
                       Read2Retrig();    /* start next measurement on second edge (measurement stays active) */
                       CheckCount();     /* and update measurement if all done */
                    }
                 }
                 else	                 /* Illegal state for High pulse measurement - should never happen */
                 {
								    /*--------------------------------------------------------------------------+
									  | STATE NAME: TRANS12                                                       |
						   			| Conditions under which this state is executed:-                           |
							 			|   Measurement = active                                                    |
							 			|   LastPin = Low                                                           |
							 			|   Transition occurred                                                     |
							 			|   Mode is High pulse measurement                                          |
							 			|Illegal state for High pulse measurement                                   |
										|Set HighPulseError flag in StatAcc                                         |
										|Set Measurement to Inactive                                                |
										|                                                                           |
									  +--------------------------------------------------------------------------*/

                    this.StatAcc = this.StatAcc | HighPulseError;
                    Measurement = Inactive;    /* Disable measurement */
                 }
              }
              else                       /* it's a period measurement */
              {
							/*--------------------------------------------------------------------------+
							| STATE NAME: TRANS13                                                       |

⌨️ 快捷键说明

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