Dear Sir,
Thanks for the reply. Finally I got it working. I didnt follow the example in the RM0016 properly, thats why it didnt work. In the example ,its not mentioned to enable the timer1 by writing 0 bit of TIM1_CR1. I was enabling the timer1 in my code and it started counting directly without the need of a trigger on TI2. I removed that line and found that the PD4 doesnt toggle on power up. It starts toggling only when 5v is applied to TI2 (PC7). It seems that CEN bit of TIM1_CR1 need to set only in reset-trigger mode and gated-trigger mode. Please find below the corrected version of the code I used. Thanks once again for the advice.
Thanks & Regards
Sajeev
main_loop.l
mov CLK_CKDIVR,#$00 ; cpu clock no divisor = 16mhz
gpio_setup:
bset PD_DDR,#4 ; set PD4 as output
bset PD_CR1,#4 ; set PD4 as pushpull
;bset PC_CR1,#7 ; enable input and pull up, uncomment if falling edge needed
timer_setup:
bres TIM1_CR1,#0 ; disable timer
bres TIM1_SR1,#6 ; clear trigger interrupt flag
mov TIM1_SMCR,#$66 ; TS = 110 and SMS = 110 , TI2 input , trigger standard mode
;bset TIM1_CCER1,#5 ; TI2 polarity falling edge , uncomment if falling edge needed
bset TIM1_IER,#0 ; enable update interrupt
bset TIM1_IER,#6 ; enable trigger interrupt
RIM
wait:
jp wait
interrupt TIM1_ISR
TIM1_ISR
bres TIM1_SR1,#0 ; clear interrupt flag
bres TIM1_SR1,#6 ; clear interrupt flag
bcpl PD_ODR,#4 ; each update interrupt at 4.09ms after counting 65535
iret
interrupt NonHandledInterrupt
NonHandledInterrupt.l
iret
segment 'vectit'
dc.l {$82000000+main} ; reset
dc.l {$82000000+NonHandledInterrupt} ; trap
dc.l {$82000000+NonHandledInterrupt} ; irq0
dc.l {$82000000+NonHandledInterrupt} ; irq1
dc.l {$82000000+NonHandledInterrupt} ; irq2
dc.l {$82000000+NonHandledInterrupt} ; irq3
dc.l {$82000000+NonHandledInterrupt} ; irq4
dc.l {$82000000+NonHandledInterrupt} ; irq5
dc.l {$82000000+NonHandledInterrupt} ; irq6
dc.l {$82000000+NonHandledInterrupt} ; irq7
dc.l {$82000000+NonHandledInterrupt} ; irq8
dc.l {$82000000+NonHandledInterrupt} ; irq9
dc.l {$82000000+NonHandledInterrupt} ; irq10
dc.l {$82000000+TIM1_ISR} ; irq11
dc.l {$82000000+NonHandledInterrupt} ; irq12
dc.l {$82000000+NonHandledInterrupt} ; irq13
dc.l {$82000000+NonHandledInterrupt} ; irq14
dc.l {$82000000+NonHandledInterrupt} ; irq15
dc.l {$82000000+NonHandledInterrupt} ; irq16
dc.l {$82000000+NonHandledInterrupt} ; irq17
dc.l {$82000000+NonHandledInterrupt} ; irq18
dc.l {$82000000+NonHandledInterrupt} ; irq19
dc.l {$82000000+NonHandledInterrupt} ; irq20
dc.l {$82000000+NonHandledInterrupt} ; irq21
dc.l {$82000000+NonHandledInterrupt} ; irq22
dc.l {$82000000+NonHandledInterrupt} ; irq23
dc.l {$82000000+NonHandledInterrupt} ; irq24
dc.l {$82000000+NonHandledInterrupt} ; irq25
dc.l {$82000000+NonHandledInterrupt} ; irq26
dc.l {$82000000+NonHandledInterrupt} ; irq27
dc.l {$82000000+NonHandledInterrupt} ; irq28
dc.l {$82000000+NonHandledInterrupt} ; irq29
end