Posted by keith on 8/4/2002, 1:44 pm In main interrupts are enabled. Code Example #include void init_TimerW(void); void main(void) void init_TimerW(void) interrupt [TIMER_W] void interval (void) There should be other applications notes on this available from Hitachi, hope it helps regards Keith
Timer I/O registers are set up so that timer output pins B, C and D output a 1 on compare match with B, C and D respectively. Values are assigned to the general registers A, B, C, D ( the value in A should be greater than those in B, C and D or else those compare matches will never happen as the counter will reset). The timer counter is initialised to zero and the counter is started in PWM mode.
#include
#pragma language=extended
void main(void);
{
init_TimerW();
set_interrupt_mask(0);
while (1)
{
}
}
{
TCRW = 0x30; /* clk/8 */
TCRW = 0xB0; /* Clears on compare match A */
TIERW = 0x71; /* Interrupt request on compare match A */
TSRW = 0x00; /* Initial value - flags cleared */
TMRW = 0x4F; /* Selects PWM mode */
TIOR0 = 0xA8; /* On compare match with B o/p =1 */
TIOR1 = 0xAA; /* on compare match with C & D o/p = 1 */
GRD = 0x3FFF; /* general register D */
GRC = 0x7FFE; /* general register C */
GRB = 0xBFFD; /* general register B */
GRA = 0xFFFC; /* general register A */
TCNT = 0x0000; /* initial value of timer counter */
TMRW = 0xCF; /* Starts TCNT in PWM mode */
}
{
TSRW &= 0x00;
}
Message Thread:
![]()
« Back to thread