2003-09-11 01:31 AM
2003-08-30 06:11 AM
I've tried to do an interrupt every 1ms using the output compare 1 of the timer b without succes.
I've attached my program but until now it does'nt work because after the first interrupt it re-enter autamaticaly in the interrupt without waiting the time put in timer. Could anyone say me how can i reset the interrupt? Thanks ________________ Attachments : prova.txt : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0C9&d=%2Fa%2F0X0000000bV7%2F1V_gSoRp9oX1XxYS1uUuR5TpYC9ag6aEcSYMvbcmd5U&asPdf=false2003-08-31 08:57 PM
You've forgotten to clear the interrupt flag.
You must read the OCF1 flag in the Status register. Read the datasheet, chapter 'timer' for more details Moppie2003-09-02 07:56 AM
Thanks, for your hepl, but it still don't work. I have already the same problem could you see the new program in order to say me if there is anithing wrong?
Thanks Enric Feixas ________________ Attachments : prova.txt : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0C4&d=%2Fa%2F0X0000000bV4%2FrIntWekPn3ZIBVLvr5lqRs1._ufHUN_4joN63LxC1A8&asPdf=false2003-09-02 09:13 PM
Hi Enric,
Try this code example. It's a ''C'' code but You can convert it in assembler. /* Definizione costanti */ #if(_freqOsc == 16 ) // < 16MHz > #define _oneMilli 1000 // costante timer free-running per ottenere il millisecondo #define _CC01 0b00001000 // divisore frequenza CPU (OSC/2) per il timer A o B a 1MHz #endif #if(_freqOsc == 8 ) // < 8MHz > #define _oneMilli 1000 // costante timer free-running per ottenere il millisecondo #define _CC01 0b00000000 // divisore frequenza CPU (OSC/2) per il timer A o B a 1MHz #endif /* Variabile WORD di supporto */ @tiny WORD Delay; // variabile per il ritardo di 1ms usata nell'interrupt timer /* Inizializzazione TIMER ''A'' */ TACR1 = 0x40; /* abilito l'interrupt out Compare su TIMER ''A''*/ TACR2 = _CC01; /* divisione del clock per il conteggio; Fcpu/x = 1MHz*/ /* Timer intarrupt handler */ @interrupt void one_milli(void) /* ROUTINE DI INTERRUPT TIMER ''A'' o ''B'' */ { if(ValBit(TASR,OCF1)) // ogni 1 millisecondo { Delay =(TAOC1HR< Delay += _oneMilli; // somma di nuovo il valore per ottenere il millisecondo TAOC1HR=(Delay>>8 ); // questa operazione effettua anche l'ack dell'interrupt TAOC1LR=Delay; // ... // Your code // } else TAOC2LR = 0x00;[ Questo Messaggio è stato Modificato da: sixtus il 03-09-2003 09:45 ]2003-09-03 03:29 AM
I've attached you're program.
First load the interrupt registers and then clear teh interrupt flag. ________________ Attachments : prova2.txt : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0BR&d=%2Fa%2F0X0000000bV1%2FVAFmZwwer8qvkzciokz4fMWFiJjJebfn7Bq1exR876s&asPdf=false2003-09-03 10:23 AM
Thanks for your help, but it still do'nt work, now I've a different problem, now it's too slowly, it spend 120ms to do the interrupt which I wanted to do in 1ms, could you look in the program what is wrong now?
Thanks Enric Feixas ________________ Attachments : prova2.txt : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0Bv&d=%2Fa%2F0X0000000bV0%2FijjgziwC6.fMLM88JK1olReJbxslAPgTyzsS_2azUto&asPdf=false2003-09-04 03:45 AM
Hello,
Look inside the attachment. Good luck. Read carefully the datasheets. ________________ Attachments : prova2.asm : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I09V&d=%2Fa%2F0X0000000bV2%2F_JMPJOLCAJb0lcJneoWsnsO8SQClw83mfWNYp6j1PQI&asPdf=false2003-09-06 11:55 AM
Thanks to all of your help, I've solved teh problem! the answer is the program that you can see attached.
But now I've a new problem because I've started to do another timer with the output compare 2 of timer A, this not and interruption because I only want to put this output in 'ON' at the time I've put in the timer A (different from B). But after putting it in on I want to put it in OFF every time that the interrupt of timer B is activated but I could'nt! Could you see in the program what is wrong? Thanks Enric Feixas ________________ Attachments : Demo.asm : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I07f&d=%2Fa%2F0X0000000bV3%2Fg59r0.aMqOkaSOuK40i.3ouGvgeGonP.EN6mSbiDBQI&asPdf=false2003-09-07 09:13 PM
Hello,
Great you solved the last problem. You're next problem are in the intterupt vectors Timer A and B has different interrupt vectors, so split up the intterupt See the attachment Succes. [ This message was edited by: Moppie on 08-09-2003 09:44 ] ________________ Attachments : Demo.asm : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0Bp&d=%2Fa%2F0X0000000bUx%2Fp38Aie.dXiP9.F7SRKxFtk06LZzf5K.bFCLHO2RSFvU&asPdf=false