Skip to main content
Visitor II
November 25, 2004
Question

Time Base with TIMERB of ST7 F 324J6B

  • November 25, 2004
  • 5 replies
  • 961 views
Posted on November 25, 2004 at 09:55

Time Base with TIMERB of ST7 F 324J6B

    This topic has been closed for replies.

    5 replies

    bonolloAuthor
    Visitor II
    November 24, 2004
    Posted on November 24, 2004 at 05:14

    good day at all, i have a problem with st7F324 i have setup the output compare enable of timerB TBCR1 = 0b01000000;

    TBCR2 = 0b00001000; with C cosmic and insert in the Vector an interrupt routine of time base ( one_milliseconds() for exsample) but whne the interrupt occours a RESET trap command is execut and the program STOP!!! how can i configure a correcte time base for the my task in the program????

    thank you at all

    Visitor II
    November 24, 2004
    Posted on November 24, 2004 at 05:41

    Could you check/attach your interrupt vector table and try with the example code below for 1 millisecond:

    void Timer_Init(void)

    {

    TAOC1HR = 0x03;

    TAOC1LR = 0xe8;

    TAOC2HR = 0x07;

    TAOC2LR = 0xD0;

    TACR1 = 0x40; // ; Timer output compare interrupt enabled

    TACR2 = 0x08; // ; Timer counter clock is CPU clk/8

    }

    @interrupt void Timer_IT_Routine(void)

    {

    unsigned char temp;

    if(TACSR & 0x48)

    {

    temp = TACSR;

    temp = TAOC1LR;

    temp = TAOC2LR;

    TACLR = 0x00;

    }

    }

    Visitor II
    November 24, 2004
    Posted on November 24, 2004 at 06:11

    Jatin,

    a little bit OT, but might be worth knowing: in your interrupt routine, the only purpose of the ''temp'' variable seems to be for reading some timer registers.

    If this is the case, the routine can be made smaller and simpler like this:

    @interrupt void Timer_IT_Routine(void)

    {

    if(TACSR & 0x48)

    {

    TACSR;

    TAOC1LR;

    TAOC2LR;

    TACLR = 0x00;

    }

    }

    The registers are read anyway (into the accumulator and then discarded), so it should work the same as before, but smaller and faster.

    Regards,

    Luca

    Visitor II
    November 24, 2004
    Posted on November 24, 2004 at 07:09

    Yes you can do it either way. Its just an example.

    bonolloAuthor
    Visitor II
    November 25, 2004
    Posted on November 25, 2004 at 09:55

    thanks at all now i try.......... :D