Re: Secondary Oscillator not running

A small embedded server. Get one for $40, including worldwide shipping.

Secondary Oscillator not running

Postby honken » Fri Feb 26, 2010 10:50 am

Hello all.

I'm having trouble starting the secondary oscillator.
According to the schematics and visual inspection there is an 32.768kHz x-tal on the SOSCI/SOSCO pin pair.
I modified the code so that the OSCIOFNC bit (#2) is set in the FOSC register and that the LPOSCEN bit (#1) is set in the OSCCON register.
I'm currently trying to confirm that they are really set, the OSCCON register is written by the __builtin_write_OSCCONL() function so it schould work.

But the result is that the RTCC isn't running and there is no activity on the SOSCI/SOSCO pins per oscilloscope inspection. Both pins are 0V.

Have anybody else tried to start the secondary oscillator, with success?
What extra setting have I missed?
Can it be that I have a faulty x-tal, caps or perhaps a short somewhere, if so any suggestions to help me find it would be appreciated.

Otherwise I got it running smoothly with a Microchip 3202 SPI ADC connected to a LM35 and HIH4000 as well as a pair of DIL relays.
Web Orchid Greenhouse well on its way.
Next thing is to attach a JPEG Camera as well.

Thank you
Tomas
User avatar
honken
Full Member
Full Member
 
Posts: 190
Joined: Fri Feb 26, 2010 10:34 am
Location: Stockholm/Sweden

Re: Secondary Oscillator not running

Postby ian » Fri Feb 26, 2010 11:28 am

Hi Tomas, sorry about the trouble. It could be a faulty cap or crystal, but could you check the crystal orientation? It is a directional component and it could be backwards. The crystal orientation wasn't checked on the first 60 units, and a few were corrected in the remaining batch before being shipped.
Got a question? Please ask in the forum for the fastest answers.
User avatar
ian
Crew
Crew
 
Posts: 10803
Joined: Mon Jul 06, 2009 6:14 am

Re: Secondary Oscillator not running

Postby honken » Fri Feb 26, 2010 1:52 pm

The x-tal seems to be correctly orientated, the sloping part pointing to the middle of the board.

I took a gamble, hoping not to brake anything,  and measured the resistance over C21, and it shows up as 0.0ohm ie short circuit.

I don't know the validity of this measurment though, as I'm also measuring over the oscillator output pin and x-tal in that point.
The resistance over C20 is "unlimited" but that pin is an input on the CPU so high-Z is to be expected.

Pehaps I should try to desolder C21 and test it "off-line" as well as checking for shorts on the PCB.
User avatar
honken
Full Member
Full Member
 
Posts: 190
Joined: Fri Feb 26, 2010 10:34 am
Location: Stockholm/Sweden

Re: Secondary Oscillator not running

Postby chiaznal » Fri Feb 26, 2010 5:33 pm

Here's my working code
Code: Select all
//------------------------------------------------------------------------------
// Timer 1 interrupt()
// Description: rtc timer
//------------------------------------------------------------------------------
void __attribute__((interrupt, auto_psv)) _T1Interrupt(void)
{
   IFS0bits.T1IF = 0;      //clear interrupt flag
   
   ++parameters.lSeconds;
   
   // Toggle led 1
   if ( LD1_O ) {
      LD1_O = 0;
   } else {   
      LD1_O = 1;
   }
}//T1Interrupt()



//------------------------------------------------------------------------------
// Time_Init()
// Description: setup timers
//------------------------------------------------------------------------------
void __attribute__((section(".text"))) Time_Init()
{
   // Timer 1 + 32kHz lp oscillator   
   __builtin_write_OSCCONL( 0x02 );   //enable low power oscillator   
   T1CON = 0;            //reset control register
   TMR1 = 0;            //reset timer
   T1CONbits.TCS = 1;      //use external clock as source
   T1CONbits.TCKPS = 3;   //set prescale to 1:256
   PR1 = 128;            //set period register so we get interupt each second (32k / 256 / 128 = 1)      
   IPC0bits.T1IP = 1;      //set interupt priority
   IFS0bits.T1IF = 0;      //clear interupt flag
   IEC0bits.T1IE = 1;      //enable interupt
   T1CONbits.TON = 1;      //turn on timer 1
}//Time_Init
chiaznal
Newbie
Newbie
 
Posts: 20
Joined: Sun Jan 10, 2010 10:07 am

Re: Secondary Oscillator not running

Postby wallabybob » Sat Feb 27, 2010 6:07 am

mackey wrote:Here's my working code


What file is that code snippet in?
wallabybob
Newbie
Newbie
 
Posts: 17
Joined: Wed Jan 27, 2010 6:02 pm
Location: Gold Coast, Australia

Re: Secondary Oscillator not running

Postby honken » Sat Feb 27, 2010 9:05 am

I found the problem. While trying to desolder C21 i saw that the solder underneath C21 withdrew to the pads.
Apparently there were some excess solderpaste that hadn't melted enough during heating, that created a shot-circuit underneath C21.
Very hard to spot with visual inspection.

Now I got the RTCC running.
User avatar
honken
Full Member
Full Member
 
Posts: 190
Joined: Fri Feb 26, 2010 10:34 am
Location: Stockholm/Sweden

Re: Secondary Oscillator not running

Postby ian » Sun Feb 28, 2010 12:27 pm

Thanks for the update honken. I'm really sorry about the problem on your board, but it's great to hear that you got it going.

I'm going to have to solder a crystal onto my board so I can do a demo, it looks like a few people are interested in this feature.
Got a question? Please ask in the forum for the fastest answers.
User avatar
ian
Crew
Crew
 
Posts: 10803
Joined: Mon Jul 06, 2009 6:14 am


Return to Web platform