This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

timer 2 as interruption tool

my purpose is to generate two opposite square signals of 40khz (period 25 us ) for a time of 400 us ie 16 periods then to regenerate that after about 100ms :
( ie 400us of 40 khz each 100ms).
i'm using timer2
in the whole project i should stay in x2 mode i'm using the AT89C5115.

so using the timer2 i generate an interruption each 12.5 us
in which i toggle the two pins i'm using to have my two square signals so i obtain half a period. by means of a counter set at 32 then decremented
if the counter is zero
i'll set to count 100ms (couldn't )

the frequency is 11.059200

the mc is used in x2

in the initialisation
MOV T2MOD,#01H ; not sure about the DCEN register
MOV RCAP2L,#??
MOV RCAP2H,#???
MOV TH2,#??
MOV TL2,#??
tmp400us EQU 32
SETB TR2



the interruption routine
CPL P1.x ;any one
CPL P1.z ; an other pin
DJNZ cpm400us,RETI
SETB CR ; démarage du timer de la PCA
MOV cpm400us,#32
MOV RCAP2H,#00 ; to have a max time but never reach 100 ms
CLR TF2 ; i'm not to do it or no each time
RETI

i write comments arount where i'm not sure.
if some one could help i'll be gratefull
thankx in advance