Hello, and welcome to the forum.
Are you using Code Warrior? I notice that some of the register names are inconsistent with the CW header file for the HC908JL8 device. I wonder if this might be your problem? Are you getting compiler or linker errors?
However, an alternative method to do what you require would be the use of PWM mode, applied to a single TIM channel (say TIM1 channel 1)? Here, the pulse repetition period would be determined by the T1MOD setting, and the pulse width by the T1CH1 register value.
For PWM mode, the overflow interrupt is not required, and the channel interrupt need be enabled only at the time you require to alter the pulse width setting (to prevent timing discontinuity the T1CH1 register would be updated within the ISR). PWM mode should produce a better timing accuracy, as well as using fewer MCU resources.
// TIM1 Ch1 setup for unbuffered PWM:
T1MOD = 1000; // Repetition period
T1CH1 = 100; // Pulse width
T1C1SC = 0x1A; // Clear O/P on compare
T1SC = 0x06; // Start timer, prescale 64
EnableInterrupts;
Regards,
Mac
Message Edited by bigmac on 2009-11-07 04:43 PM