thank you very much!!!!
[quote:759c67b743="albertsm"]tcb0 is a different timer indeed.
here the best way is to use compare mode. first you calculate it :
[code:1:759c67b743]Const Ctbo0per =(0.5 / 1000) /(1 /(_xtal / 2)) 'for 0.5 ms[/code:1:759c67b743]
the 0.5/1000 is for 0.5 ms, you can adjust that
the PER register servers as compare top.
[code:1:759c67b743]Tcb0_ccmp = Ctbo0per[/code:1:759c67b743]
then you config the timer :
[code:1:759c67b743]Config Tcb0 = Periodic_int , Prescale = 2 , Run = On[/code:1:759c67b743]
the interrupt is defined as usual :
[code:1:759c67b743]Declare Sub Tcb0_isr()
On Tcb0_int Tcb0_isr
Enable Tcb0_ovf 'or tcb0_int
Enable Interrupts[/code:1:759c67b743]
...
[code:1:759c67b743]Sub Tcb0_isr()
Tcb0_intflags = 1 'reset capture/ccmp interrupt
End Sub
[/code:1:759c67b743]
notice that tcb0 has 2 interrupts which are shared. but overflow is not used in this sample[/quote:759c67b743]
↧