Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC24 Timer1 not counting , but is now.

Status
Not open for further replies.

granddad

Well-Known Member
Most Helpful Member
This is a snippet of start up code for a PIC24EP256MC204 project I have been working on....( FRC oscillator switching to FRC+PLL). it works fine.... until I wanted to count seconds from a DS1338 .. I found out a couple of hours ago, it stops Timer 1 from counting using the T1CK input pin … This PIC does not have RTCC so no secondary oscillator, but it seems the bit (1) in OSCCON to enable it is still active (red text) , enabling the SOSC interferes with the T1CK input, my mistake was to paste the code from a 24F device with RTCC and I had not appreciated the difference … thought I would share my head scratching.

Code:
PLLFBD = 33; //M
CLKDIVbits.PLLPOST = 3; // N2
CLKDIVbits.PLLPRE = 0; // N1
__builtin_write_OSCCONH(0x01); // Initiate Clock Switch to FRC oscillator with PLL (NOSC=0b001)

__builtin_write_OSCCONL(OSCCON | 0x03); // Enable Switch & sec osc (PIC24F ! )
__builtin_write_OSCCONL(OSCCON | 0x01); // Enable Switch
while (OSCCONbits.COSC != 0b001);// Wait for Clock switch to occur
while (OSCCONbits.LOCK != 1);// Wait for PLL to lock
// REF CLOCK IS PIN 8 - RB10
// FSC and PLL now at 16Mhz
OSCTUN = 0x0030; // TUNE +- 8MhzOSC

---- end of snippet ---
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top