2004-06-28 03:36 AM
2004-06-15 01:24 AM
Hi, I'm trying to do a PWM with the OCMP1 and it just doesn't do anything, could anyone say me what I'm doing wrong?
________________ Attachments : PWM.txt : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0BL&d=%2Fa%2F0X0000000bUr%2FWyoGllv.X8iOpuwMABFlu47xb.B8mHNKvayeNA9W7F4&asPdf=false2004-06-15 03:39 AM
The timer interrupt works with flags!
It's depending on which flag the uC jumps to the interrupt vector. To leave the interrupt vector, you MUST clear the flag! ;Clear Timer interrupt flags ld A,TBSR ;ld A,TBIC1LR ;clear ICF1 flag ld A,TBOC1LR ;clear OCF1 flag ld A,TBCLR ;clear TOF flag ld A,TBIC2LR ;clear ICF2 flag ld A,TBOC2LR ;clear OCF2 flag iret ;back to main program2004-06-15 05:26 AM
thanks for the answer,
but even I've put that, the problem is that the interrupt never starts. ________________ Attachments : PWM.txt : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I08X&d=%2Fa%2F0X0000000bUt%2F4r9mb7rsnRKOHD.XqCkQaHFCif1z3LeFXdtF1XSN9n4&asPdf=false2004-06-15 08:54 PM
Do you have enabled the interrupts after init?
rim ;enable all interrupts2004-06-16 05:41 AM
yes, I do.
I can't understand what's wrong2004-06-16 07:49 PM
You have initialise PWM output PB1 (OCMP1_A) to open drain.
Do you have a pull-up resistor at PB1? I have attached a piece a small piece of code to initialise PWM. I can't find any mistake in your code. ________________ Attachments : PWM.asm : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0AJ&d=%2Fa%2F0X0000000bUs%2FxhKVcEZ.QVU.lwKjNI8YBBPsKgzy0sWv4k5omGzQ4JY&asPdf=false2004-06-18 02:23 AM
Hello, I used the PWM on pin PC1 two years ago.
It is well working. The C code used is this: PCDDR=0x02; PCOR=0x02; TBCC1=1; TBOLVL1=0; TBOLVL2=1; TBTOIE=1; TBOC1E=1; TBOC2HR=0x02;//period 1.3KHz TBOC2LR=0xe2; TBOC1HR=0x01;//duty cycle 50% TBOC1LR=0x71; TBPWM=1; You see the interrupt in timer_b on flag TBICF1 I hope it is helpful for you2004-06-20 11:49 PM
I've solved my problem, thanks.
2004-06-28 03:36 AM
Sorry, but I need your help another time.
The timer is working in PB1, but apart from that I want to use also and external interrupt in PA2,which is an square signal (Ieada it by rising and faling edge) these two interrupts worked separated but not together, I don'tubnderstand why but when I use the instruction rim after put on the PWM the program stops, but the PWM still working. Could anyone say me which is the problem? thanks. ________________ Attachments : PWM.asm : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I06g&d=%2Fa%2F0X0000000bUq%2FVW9v_3c9717Ev9YpHaV0Ru4BhqIcnvHQ9nec2kJ.dBk&asPdf=false