Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
11/08/05 08:14
Read: times


 
#103407 - pulse width
Responding to: ???'s previous message
i have that cookbook and although it explain things and i have some idea now, im still a bit lost.

i have this code for the cygnal C8051F023, where the PCA is in high speed mode, but not quite sure what exactly to do to measure the pulse width.

goes is as follows :

sbit DOUTX = P0^6; // define PWM output port pin

XBR0 = 0x15; // enable CEX0 at P0.6
XBR2 = 0x44; // enable crossbar and weak
// pull-ups

P0MDOUT = 0x11; // Output configuration for P0

PCA0MD = 0x02; // disable CF interrupt
// PCA time base = SYSCLK / 4

PCA0CPL0 = (0xff & PWM); // initialize PCA compare value
PCA0CPH0 = (0xff & (PWM >> 8));
PCA0CPM0 = 0x4D; // CCM0 in High Speed output mode

EIE1 |= 0x08; // enable PCA interrupt
EA = 1; // Enable global interrupts
PCA0CN = 0x40; // enable PCA counter

void PCA_ISR (void) interrupt 9
{
if (CCF0) {

if (DOUTX) { // process rising edge

xVal1 = PCA0CPL0;
xVal1 += PCA0CPH0<<8;

} else { // process falling edge

xVal2 = PCA0CPL0;
xVal2 += PCA0CPH0<<8;

pulseWidthx = xVal1 - xVal2;

}

CCF0 = 0; // clear compare indicator
}

is that correct? do i take the PCA0CPLx register values? when debugging, it triggers on the rising and falling edge, im just not sure if im measuring the pulse width correctly.



List of 9 messages in thread
TopicAuthorDate
PWM            01/01/70 00:00      
   for the PCA            01/01/70 00:00      
      pulse width            01/01/70 00:00      
         input or output ?            01/01/70 00:00      
            input            01/01/70 00:00      
               output != input            01/01/70 00:00      
                  ISR            01/01/70 00:00      
                     CEX1            01/01/70 00:00      
   Tilt sensor            01/01/70 00:00      

Back to Subject List