Paul Laiming

ICG Variance - MC9S08AW16

Discussion created by Paul Laiming on Sep 16, 2008
Latest reply on Sep 20, 2008 by Jim Donelson
I am using the MC9S08AW16 as a motor control supervisor and speed control. I am using Codewarrior 5.9 and processor expert for initialization and using the ICG as main clock.  I  monitor motor speed by monitoring a hall effect sensor in the motor.  When the hall effect sensor triggers, I start a timer and measure time until the next hall event.  This has worked pretty well for the first few boards, but the latest board is significantly off in measurement.

Attached is my code to measure the time:

void getperiod(void){
  TPM2MOD = 0xffff;
  KBI1PE_KBIPE0 = 1; // enable keyboard enable bit 0
  KBI1SC_KBACK = 1; // clear interrupt
  while(!KBI1SC_KBF); // wait for keyboard interrupt
  KBI1SC_KBACK = 1; // clear interrupt
  TPM2CNT = 0;  // zero the timer
  while(!KBI1SC_KBF); // wait for keyboard interrupt
  KBI1SC_KBACK = 1; // clear interrupt
  HallPeriod = TPM2CNT; // total period
}

Could this be due to variance in the ICG? What is the best way to check this?

-paul

Added p/n to subject.


Message Edited by NLFSJ on 2008-09-16 03:42 PM

Outcomes