Hot!Time 7 and 9 of dsPIC33EP512MU810

Author
kappa_am
New Member
  • Total Posts : 16
  • Reward points : 0
  • Joined: 2015/05/06 07:24:30
  • Location: 0
  • Status: offline
2018/02/13 18:05:33 (permalink)
0

Time 7 and 9 of dsPIC33EP512MU810

Hi folks,
I have couple of questios about dsPIC33EP series timer.
Why configruration of the PWM set interrupt of timer 9 enable? is this timer used in PWM section?
 
I have written a program in which I used timer 6&7 as 32-bit timer. the interrupt works. in the propgarm I am changing PR6 and 7 and T6CON. after 4-5 times change in this words the intrrupt stops working while the intrrubt enable bit is set!
this section of the program and its related interrupt are as follow:
 
The program is rather large so I've sent just this section to keep it semple.
 
     void Timer7Int() iv IVT_ADDR_T7INTERRUPT {
      OCSTP=((signed short) OCSTP + CRCNST);
      if (OCSTP>180){
       //T6CON= T6CON & 0x7FFF;
       T7IE_bit = 0;
       OCSTP=181;}
      else {
       if (OCSTP<65){
       // T6CON= T6CON & 0x7FFF;
        T7IE_bit = 0;
        OCSTP=64;}}
      CURLMT=((long) OCSTP * (long) INOM)>>6;
      T7IF_bit = 0;}

 
   if(BUFFA0[1]>INOM || BUFFA0[2]> INOM || BUFFA0[3]> INOM ){ //Overcurrent Protection
       if (SEVF>OCSTP) {
        if (CLOR != 1) {
          CRCNST=-1;
         T6CON=0x0038; ////
         TMR7 = 0x00; // Clear 32-bit Timer (msw)
         TMR6 = 0x00;
         PR7=TIMERHH; //timer/60M
         PR6=TIMERHL;
         IPC12= 0x0004;
         T7IF_bit = 0;
         T7IE_bit = 1;
         T6CON=T6CON | 0x8000;
         CLOR=1;}}
       else {
        if (CLOR != 2) {
         CRCNST=-1;
         CLOR=2;
         T6CON=0x0018; ////
         TMR7 = 0x00; // Clear 32-bit Timer (msw)
         TMR6 = 0x00;
         PR7=TIMERSH; //timer/60S
         PR6=TIMERSL;
         IPC12= 0x0004;
         T7IF_bit = 0;
         T7IE_bit = 1;
         T6CON=T6CON | 0x8000;}}
       if ((BUFFA0[1]>CURLMT)||(BUFFA0[2]>CURLMT)||(BUFFA0[3]>CURLMT)){
        FSTSIND=FSTSIND|0x0002;}}
       else {
        if(OCSTP<180) {
         if (CLOR != 3) {
          CRCNST=1;
          CLOR=3;
          T6CON=0x0038; //38
          TMR7 = 0x00; // Clear 32-bit Timer (msw)
          TMR6 = 0x00;
          PR7=TIMERRH; //timer/60M
          PR6=TIMERRL;
          IPC12= 0x0004;
          T7IF_bit = 0;
          T7IE_bit = 1;
          T6CON=T6CON | 0x8000;}}}

 
I have checked every thing. I would be grateful if you give me some hints.
 
Thank you.
 
by the way, when T7 interrupt stop working, other interrupts do not stop.
 
#1

7 Replies Related Threads

    jtemples
    Super Member
    • Total Posts : 10949
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: Time 7 and 9 of dsPIC33EP512MU810 2018/02/13 18:16:03 (permalink)
    4 (1)
    the intrrupt stops working

     
    Have you looked at the state of the TxCON in the debugger when it stops to ensure the timer is on?  The interrupt won't fire if the timer is off, which is something you're doing several places in your code.
     
    T6CON=T6CON | 0x8000;

     
    Don't do things like that; use the T6CONbits.xxx definitions.  Code like that is error-prone and unreadable.
    #2
    Aussie Susan
    Super Member
    • Total Posts : 3331
    • Reward points : 0
    • Joined: 2008/08/18 22:20:40
    • Location: Melbourne, Australia
    • Status: offline
    Re: Time 7 and 9 of dsPIC33EP512MU810 2018/02/13 19:02:12 (permalink)
    0
    I don't see where Timer 9 is referenced in that code at all so I'm not sure what that has to do with your issue of Timer 6/7.
    I do see that you are disabling the Timer 7 IE within the ISR but I can't tell what conditions are true for that to occur. However that certainly would stop further interrupts from being recognised.
    I'm not sure which PWM you are referring to : the Output Compare peripheral only uses Timers 1 to 5 (and Fp) and the fast PWM module uses either Fosc or two external SYNCIx signals that are connected to pins via PPS.
    Susan
    #3
    kappa_am
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2015/05/06 07:24:30
    • Location: 0
    • Status: offline
    Re: Time 7 and 9 of dsPIC33EP512MU810 2018/02/13 21:59:39 (permalink)
    0
    Yes, I Paused the debugger when the intrruptstps and the timer control word's "T6CON" value is ok. I checked interrupt enable bit and GEI also. all ok. I don't know what is the cause!
    post edited by kappa_am - 2018/02/13 22:01:04
    #4
    kappa_am
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2015/05/06 07:24:30
    • Location: 0
    • Status: offline
    Re: Time 7 and 9 of dsPIC33EP512MU810 2018/02/13 22:03:57 (permalink)
    0
    I have checked the interrupt enable bit and "T6CON" all values are ok while the interrupt fails.
    I do not used T9 at all. I was checking T7 interrupt enable bit that I noticed that when MC-PWM module  gets activated the interrupt enable bit of this timer gets set. I wonder why? I looked at datasheet but I couldn't manage to find any related information.
    #5
    kappa_am
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2015/05/06 07:24:30
    • Location: 0
    • Status: offline
    Re: Time 7 and 9 of dsPIC33EP512MU810 2018/02/14 14:39:27 (permalink)
    0
    I found interesting thing. when I take the timer and interrupt dissable bit  out of interrupt it works fine. The disabling logic is same. The question is why when the interrupt Enable/diable bit is inside interrupt routine it fails to generate interrupt after a while, while both of GIE and T7IE are not zero and timer 6 and 7 (32bit) is ON!!!
    #6
    Gort2015
    Klaatu Barada Nikto
    • Total Posts : 2645
    • Reward points : 0
    • Joined: 2015/04/30 10:49:57
    • Location: 0
    • Status: offline
    Re: Time 7 and 9 of dsPIC33EP512MU810 2018/02/14 15:53:31 (permalink)
    0
    T6CON=0x0038; //magic numbers

    Use the macros.
    T1CON=_T1CON_TCKPS0_MASK|_T1CON_TCKPS1_MASK|_T1CON_TON_MASK;

    MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
    https://www.youtube.com/watch?v=Iu1qa8N2ID0
    + ST:Continues, "What Ships are Made for", Q's back.
    #7
    Aussie Susan
    Super Member
    • Total Posts : 3331
    • Reward points : 0
    • Joined: 2008/08/18 22:20:40
    • Location: Melbourne, Australia
    • Status: offline
    Re: Time 7 and 9 of dsPIC33EP512MU810 2018/02/14 18:48:51 (permalink)
    0
    kappa_am
    The question is why when the interrupt Enable/diable bit is inside interrupt routine it fails to generate interrupt after a while, while both of GIE and T7IE are not zero and timer 6 and 7 (32bit) is ON!!!

    Not seen enough of your code to do more than guess but this sounds like a timing problem - you have no idea what the ISR has interrupted when it has triggered. At least when these things are in the mainline code, you have better control over what is happening around them.
    Not sure why we are suddenly talking about GIE but that should be set right at the start and left alone completely. As you said at the start, other interrupts keep going so GIE has to be set. Anyway, that part of the chip has been around since the year 'dot' and there are no errata items about (relevant) interrupts or timers.
    Susan
    #8
    Jump to:
    © 2018 APG vNext Commercial Version 4.5