Skip to main content
Visitor II
June 28, 2004
Question

PWM with st72254G

  • June 28, 2004
  • 9 replies
  • 1654 views
Posted on June 28, 2004 at 12:36

PWM with st72254G

    This topic has been closed for replies.

    9 replies

    efeixasAuthor
    Visitor II
    June 15, 2004
    Posted on June 15, 2004 at 10:24

    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=false
    Visitor II
    June 15, 2004
    Posted on June 15, 2004 at 12:39

    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 program

    efeixasAuthor
    Visitor II
    June 15, 2004
    Posted on June 15, 2004 at 14:26

    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=false
    Visitor II
    June 16, 2004
    Posted on June 16, 2004 at 05:54

    Do you have enabled the interrupts after init?

    rim ;enable all interrupts
    efeixasAuthor
    Visitor II
    June 16, 2004
    Posted on June 16, 2004 at 14:41

    yes, I do.

    I can't understand what's wrong

    Visitor II
    June 17, 2004
    Posted on June 17, 2004 at 04:49

    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=false
    Visitor II
    June 18, 2004
    Posted on June 18, 2004 at 11:23

    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 you
    efeixasAuthor
    Visitor II
    June 21, 2004
    Posted on June 21, 2004 at 08:49

    I've solved my problem, thanks.

    efeixasAuthor
    Visitor II
    June 28, 2004
    Posted on June 28, 2004 at 12:36

    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