This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

CAPCOM T0 counter mode

Hello all,

I am a newbie in microcontroller programming. I am using ST10 microcontroller. My problem is

to determine the speed of a BLDC motor by using three hall sensors.The hall sensors are

connected to ports P8_2,P8_3 and P8_4.My idea is to use only one hall sensor (if possible)

to count the number of pulses in a certain period of time. Each hall sensor remains high for

180 electrical degree and low for the other 180°.My motor has 3 pole-pairs. So, three

electrical cycles are needed for the completion of a mechanical cycle.From this information

I can calculate the speed if I can count the number of pulses.If I am right, for one

mechanical cycle, 6 pulses (3 high, 3 low) can be detected.

I would like to use CAMCOM T0 in counter mode:

//CAPCOM T0 counter mode
void Capcom0Init(void)
{
T01CON = 0x0009;
T0 = 0x0000;
T0REL = 0x0000;
T01CON |= 0x0040;
}

To be true, I got this code from a DC motor control code. I am not sure,how and which port

can be associated with the above code to give T0 values.

The following skeleton (taken from the same source) function calculates the speed:

// Function: GetSpeed
// Purpose: Counts the number of pulses over a given time interval. Uses this value to

calculate the speed
// It uses CAPCOM 16, which is connected to P8_0. CAPCOM 16 is timed with Timer 7.
// Input conditions: P3_0 configured as input (in initialize).
// Destroys: P3_0
// Returns: Speed (m/sec)

float GetSpeed(int ticks,float timeInterval)
{
-----

}



Would be please anybody be kind to clarify my doubts?

Thanks

0