• AVR Freaks

Hot!Inconsistent Timer1 interrupt using DSPIC33FJ32GS606

Author
shahidatiq
New Member
  • Total Posts : 7
  • Reward points : 0
  • Joined: 2017/03/11 13:38:25
  • Location: 0
  • Status: offline
2020/03/24 10:14:25 (permalink)
0

Inconsistent Timer1 interrupt using DSPIC33FJ32GS606

Hi dears
I am trying to generate a timer interrupt using timer1 to generate a square wave with a period of 20 usec. However, I am receiving inconsistent frequency at the output port. If I set the oscilloscope time scale in usec, I  can see a well-desired waveform as shown in Fig1.
 
However, as I increase the time scale of the scope in 2 msec per division, I see the waveform as shown in Fig.2 where I can see zero signal and two different frequencies output.
If I further increase the time scale of the scope to 50 msec/div I can see the waveform as shown in Fig.3. It sows some time the interrupts are being generated and some times not. I have attached an LED at this port and the LED is blinking at the rate as shown in Fig.3.
 
What I am expecting is a consistent square wave as shown in Fig.1. I am using the internal FRC clock of the DSPIC33FJ32GS606 with PLL to operate the device at 40 MIPs. I have not used any external crystal for clocking this device. Whenever I use PWM at this device, the same behavior as Fig.3 is observed at PWM pins. For some period of time, I receive accurate PWM but for another interval of time, I receive zero signal. Suggest some solutions to this problem. Is it possible that FRC stop working for some reason at the intervals where I am receiving a DC signal instead of a square wave?
 
My code is as follows:
 
 
#include <p33fj32GS606.h>
_FOSCSEL(IESO_ON & FNOSC_FRCPLL);
_FOSC(POSCMD_NONE & OSCIOFNC_OFF & FCKSM_CSECME);
void __attribute__((__interrupt__, __auto_psv__)) _T1Interrupt(void);
int main(void)
{
_PLLPRE = 5; // divides 7.37MHz with 7
_PLLDIV = 152; // Multiply above resultant with 152
_PLLPOST = 0; // Divides above resultant of Mhz to MIPs of 40 MIPs
T1CONbits.TON = 0; // Disable Timer
T1CONbits.TCS = 0; // Select internal instruction cycle clock
T1CONbits.TGATE = 0; // Disable Gated Timer mode
T1CONbits.TCKPS = 0b00; // Select 1:1 Prescaler
TMR1 = 0x00; // Clear timer register
PR1 = 400; // Load the period value
IPC0bits.T1IP = 0x01; // Set Timer1 Interrupt Priority Level
IFS0bits.T1IF = 0; // Clear Timer1 Interrupt Flag
IEC0bits.T1IE = 1; // Enable Timer1 interrupt
T1CONbits.TON = 1; // Start Timer
_TRISF0 = 0; // Configure RF0 pin as output
while(1)
{
}
}
void __attribute__((__interrupt__, no_auto_psv)) _T1Interrupt(void)
{
_LATF0=!_LATF0; // Generate square wave at RF0 pin

IFS0bits.T1IF = 0; // Clear Timer1 Interrupt Flag
}
 

Attached Image(s)

#1

12 Replies Related Threads

    Severino
    Starting Member
    • Total Posts : 35
    • Reward points : 0
    • Joined: 2014/04/30 01:50:28
    • Location: 0
    • Status: offline
    Re: Inconsistent Timer1 interrupt using DSPIC33FJ32GS606 2020/03/24 10:19:24 (permalink)
    0
    Is the WDT active?
     
    #2
    shahidatiq
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2017/03/11 13:38:25
    • Location: 0
    • Status: offline
    Re: Inconsistent Timer1 interrupt using DSPIC33FJ32GS606 2020/03/24 10:31:53 (permalink)
    0
    I have not configured WDT. By default it is active.
    #3
    Severino
    Starting Member
    • Total Posts : 35
    • Reward points : 0
    • Joined: 2014/04/30 01:50:28
    • Location: 0
    • Status: offline
    Re: Inconsistent Timer1 interrupt using DSPIC33FJ32GS606 2020/03/24 10:53:04 (permalink)
    0
    Then you might need to periodically reset it (or to disable it).
     
    #4
    shahidatiq
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2017/03/11 13:38:25
    • Location: 0
    • Status: offline
    Re: Inconsistent Timer1 interrupt using DSPIC33FJ32GS606 2020/03/24 11:00:23 (permalink)
    0
    I have disabled the WDT by using the following syntax
     
    _FWDT( FWDTEN_OFF )
     
    However, there is no change in the output
    #5
    shahidatiq
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2017/03/11 13:38:25
    • Location: 0
    • Status: offline
    Re: Inconsistent Timer1 interrupt using DSPIC33FJ32GS606 2020/03/25 02:25:15 (permalink)
    0
    Thanks, Severino
     
    Now I found that I was using LM7805 voltage regulator in my power supply circuit to the microcontroller. This voltage regulator was shutting down periodically due to thermal protection. That was why I was observing DC signal at the output port at that time in Fig.3
    Regards 
    #6
    Severino
    Starting Member
    • Total Posts : 35
    • Reward points : 0
    • Joined: 2014/04/30 01:50:28
    • Location: 0
    • Status: offline
    Re: Inconsistent Timer1 interrupt using DSPIC33FJ32GS606 2020/03/25 03:10:37 (permalink)
    0
    Great, so you'll be able to use a different power supply?
     
    Strange that the LM7805 shuts down in such regular intervals.
     
    #7
    du00000001
    Just Some Member
    • Total Posts : 3477
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: Inconsistent Timer1 interrupt using DSPIC33FJ32GS606 2020/03/25 04:10:25 (permalink)
    0
    An LM7805 under thermal shutdown?
    What loads have you attached beyond the microcontroller?

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #8
    ric
    Super Member
    • Total Posts : 26159
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Inconsistent Timer1 interrupt using DSPIC33FJ32GS606 2020/03/25 04:17:04 (permalink)
    0
    At a guess, it has 12V or more on the input, so is having to drop 7 volts.
    It must have a few 100mA going though it to generate a few watts of heat though.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #9
    JPortici
    Super Member
    • Total Posts : 925
    • Reward points : 0
    • Joined: 2012/11/17 06:27:45
    • Location: Grappaland
    • Status: offline
    Re: Inconsistent Timer1 interrupt using DSPIC33FJ32GS606 2020/03/25 05:58:01 (permalink)
    0
    I've had an issue in the past with 78xx regulators from ST in TO-92 and TO-220 package. All genuine, from different manufacturing lots.
    The issue was that they went into thermal protection while dissipating significantly less power that a thermal calculation would suggest, using the parameters from the datasheet. Changing the component to one from a different manufacturer would solve the issue. Three legged regulators from ST has been in my blacklist ever since
    #10
    mpgmike
    Super Member
    • Total Posts : 389
    • Reward points : 0
    • Joined: 2014/01/23 17:27:06
    • Location: NJ
    • Status: offline
    Re: Inconsistent Timer1 interrupt using DSPIC33FJ32GS606 2020/03/25 07:57:57 (permalink)
    0
    I put a small resistor between my high voltage and the LM780x to somewhat buffer the current.  This allows for better capacitive filtering the input as well.

    I don't need the world to know my name, but I want to live a life so all my great-grandchildren proudly remember me.
    #11
    ric
    Super Member
    • Total Posts : 26159
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Inconsistent Timer1 interrupt using DSPIC33FJ32GS606 2020/03/25 12:23:21 (permalink)
    0
    I assume any 7805 in a to92 package was actually a 78L05, which would have much lower thermal dissipation capacity.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #12
    du00000001
    Just Some Member
    • Total Posts : 3477
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: Inconsistent Timer1 interrupt using DSPIC33FJ32GS606 2020/03/25 15:11:00 (permalink)
    0
    TO-92 has a maximum nominal power dissipation of 600 mW.
    This is not much considering the 7805 has a minimum voltage drop of around 2 V.
    And with a supply of 12 V even a meagre 100 mA would be too much.

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #13
    Jump to:
    © 2020 APG vNext Commercial Version 4.5