AnsweredAssumed Answered

A problem when using the PLA to get the width of pulse

Question asked by liang on Jul 14, 2011
Latest reply on Jul 20, 2011 by liang

hello!

    I use the PLA of ADUC7026 to  get the width of pulse ,I refer the article"Measuring Duration of a Short Pulse on the ADuC702x Family" by Aude Richard,the period of pulse i used is 23.44ms,and 833us, but when the program running I found the T1CAP is 0,and the T1VAL is from 0 to 4292696439 ,I don't konw why the T1CAP is always 0,

    the program i used is :

#include "ADuC7026.h"
long pulse;
void IRQ_Handler(void); // IRQ Function Prototype
void PLA_init(void);
void delay (int length)
{
while (length >=0)
    length--;
}
void sys_clk_init(unsigned char clk)
{
PLLKEY1=0xAA;
PLLCON=0x01;  //PLL配置 
PLLKEY2=0x55;
POWKEY1=0x01;
POWCON=clk;  //CPU时钟配置为
POWKEY2=0xF4;
}
int main (void)
{
  long double T_pulse;
//  IRQ = My_IRQ_Function; // Specify Interrupt Service Routine
  sys_clk_init(0);  //配置为41.78M
  GP2CON = 0x00;  // 设置 P2.4 P2.5 P2.6 P2.7 为GPIO
 
  PLA_init(); 
 
  IRQEN = 0x080000; // enable PLA IRQ0
//  My_IRQ_Function();
  while (1)
  {
  T_pulse=pulse/41780000;
  }
 
}
/********************************************************************/
/* */
/* Interrupt Service Routine */
/* */
/********************************************************************/
void IRQ_Handler()
{
  if ((IRQSTA & PLA_IRQ0_BIT) == 0x00080000) // PLAIRQ0
      {
      T1CON = 0x32180; // start Timer1. capture PLAIRQ1
      IRQCLR = 0x80000; // disable PLA IRQ0
      IRQEN = 0x00100000; // enable PLA IRQ1
//    GP2DAT =0xF0000000;            just  to test if IRQ is enterd,in fact it entered
      }
  if ((IRQSTA & PLA_IRQ1_BIT) == 0x00100000) // PLAIRQ1
      {
      pulse = T1CAP; // read the capture event
      IRQCLR = 0x00100000; // disable PLA IRQ1
      IRQEN = 0x80000; // enable PLA IRQ0
      T1LD = 0x00; // to reset timer1
      T1CON = 0xC0; // reset timer1
      T1CON = 0; // stop timer1
//    GP2DAT =0xF0F00000;  // just  to test if IRQ is enterd,in fact it entered

//    delay (2000000);   
      }
  return ;
}
/********************************************************************/
/* */
/* PLA
*/
/* */
/********************************************************************/
void  PLA_init()
{
  // Configure Port Pins for PLA mode
GP3CON = 0x300000;
// GP4CON = 0x3300000;
// Configure individual elements
PLAELM13 = 0x0035;
PLAELM14 = 0x010B;
// Clk Source configuration
// PLACLK = 0x0000;
// IRQ output configuration
PLAIRQ = 0x1E1D;

 


  return ;

}

 

i ues the logic analyzer to test my program

 

from the picture the period of T1VAL is 2.482796s (0-4292696439), and the T1CAP is always 0,

I don't kow why?

 

 

 

 

many thanks!

liang

Outcomes