CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

dspic33fj256gp506 timer2 external clock

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
mahdi70



Joined: 05 Jan 2016
Posts: 44

View user's profile Send private message

dspic33fj256gp506 timer2 external clock
PostPosted: Thu Mar 17, 2016 10:14 am     Reply with quote

hi... I bought 33fj256gp506 and this micro have external pin for t2ck and no need to use #pin_select. In #pin_select mode the internal and external clock get sync. Main clock 50 MHz and external clock for Timer2 is 100 MHz but its not work. Why?

PIN_C1 for t2ck

tnx
temtronic



Joined: 01 Jul 2010
Posts: 9163
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Mar 17, 2016 12:34 pm     Reply with quote

You need to post your program ! Complete, small, compilable like the 1Hz LED program.
Your PIC might not work due to a hardware error NOT code relate but until we see your code, no one can say 'Yes, the code is wrong'.

Jay
jeremiah



Joined: 20 Jul 2010
Posts: 1322

View user's profile Send private message

PostPosted: Thu Mar 17, 2016 2:43 pm     Reply with quote

Just as a note, the datasheet for the chip, page 275, table 25-23, specifies timing requirements for the external timer 2 input.

It specifies the minimum period is Tcy + 40ns. The data you have given won't work within the data sheet parameters

Fcy = 50MHz/2 = 25MHz
Tcy = 40ns

Minimum period for T2CK is Tcy + 40ns = 40ns + 40ns = 80ns
Maximum frequency for T2CK is 12.5 MHz while you are supplying 100MHz

Now if you are using the PLL or some prescalers on the input, that would change things, but the info you provided doesn't suggest this.

Something to keep in mind. Even if it appears to work in one configuration, being out of spec of the datasheet is not a good thing.
mahdi70



Joined: 05 Jan 2016
Posts: 44

View user's profile Send private message

PostPosted: Thu Mar 17, 2016 5:59 pm     Reply with quote

temtronic wrote:
You need to post your program ! Complete, small, compilable like the 1Hz LED program.
Your PIC might not work due to a hardware error NOT code relate but until we see your code, no one can say 'Yes, the code is wrong'.

Jay


Code:
#include <33FJ256GP506.h>

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES CKSFSM                   //Clock Switching is enabled, fail Safe clock monitor is enabled
#FUSES NOJTAG                   //JTAG disabled

#device ICSP=1
#use delay(crystal=50MHz)

#INT_TIMER2
void  timer2_isr(void)
{
output_toggle(pin_g0);//interrupt every 100ms
}
void main()
{

   setup_timer2(TMR_EXTERNAL | TMR_DIV_BY_256, 40000);//100 mhz external clock

   enable_interrupts(INT_TIMER2);
   enable_interrupts(INTR_GLOBAL);

   while(TRUE)
   {
      //TODO: User Code
   }

}
mahdi70



Joined: 05 Jan 2016
Posts: 44

View user's profile Send private message

PostPosted: Thu Mar 17, 2016 6:08 pm     Reply with quote

jeremiah wrote:
Just as a note, the datasheet for the chip, page 275, table 25-23, specifies timing requirements for the external timer 2 input.

It specifies the minimum period is Tcy + 40ns. The data you have given won't work within the data sheet parameters

Fcy = 50MHz/2 = 25MHz
Tcy = 40ns

Minimum period for T2CK is Tcy + 40ns = 40ns + 40ns = 80ns
Maximum frequency for T2CK is 12.5 MHz while you are supplying 100MHz

Now if you are using the PLL or some prescalers on the input, that would change things, but the info you provided doesn't suggest this.

Something to keep in mind. Even if it appears to work in one configuration, being out of spec of the datasheet is not a good thing.


when the chip have external pin for extern clock the internal and external clock not sync..I am right?
in pin_select mode the external and internal clock sync
Ttelmah



Joined: 11 Mar 2010
Posts: 19338

View user's profile Send private message

PostPosted: Fri Mar 18, 2016 3:52 am     Reply with quote

This is one of those 'data sheet' faults.....

If you look at the block diagrams for all the Timer 2 etc., timers, you will see that in the signal path from the input, there is still a 'sync' block, whatever source you use (this is distinct from the 'gate' sync, which you can enable separately).

This thread covers it quite well:

<http://www.microchip.com/forums/m749886.aspx>

Only timer1, is a type A type timer. Only type A timers can run fully async.

The data sheet conflicts with itself in several places over this....
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group