Difficulty configuring SOSC pins as digital io

(instructions, reset, WDT, specifications...) PIC17Cxx, PIC18Fxxx

Difficulty configuring SOSC pins as digital io

Postby sjg » Tue Jul 01, 2014 8:29 pm

Hi,

On the PIC18F67J94, pins RC0 and RC1 are available for use as secondary oscillator i/o. I wish to use them for digital IO, but am having a difficult time with the configuration.

Per the family data sheet, these pins are configured as digital inputs upon any device reset. I suspect I am spoiling that with the configuration settings (below), but I can't see where.

There is an item I don't understand in the possible config settings. Per mplab, SOSCEL has just two options: either "Low Power T1OSC/SOSC circuit selected" or "Digital (SCLKIL mode". Is the SOSCEL setting ignored unless one also configures, for example, FOSC = SOSC?

I have TRISC = 0x00;
and the following will change all RC bits except RC0,1. Those pins remain at 0V.
LATC = 0xFF
LATC - 0x00;

Code: Select all
   #pragma config STVREN   = ON         // Stack overflow reset
   #pragma config XINST    = OFF      // Extended instruction set
   #pragma config BOREN    = ON       // BOR Enabled
   #pragma config BORV     = 0         // BOR Set to "2.0V" nominal setting
   #pragma config CP0      = OFF         // Code protect disabled
   #pragma config FOSC     = FRCPLL    // Firmware should also enable active clock tuning for this setting
   //#pragma config SOSCSEL  = LOW // SOSC circuit configured for crystal driver mode
   //#pragma config SOSCSEL = DIG   // DIG -> Digital (SCLKI) mode
   #pragma config CLKOEN   = OFF       // Disable clock output on RA6
   #pragma config IESO     = OFF         // Internal External (clock) Switchover
   #pragma config PLLDIV   = NODIV     // 4 MHz input (from 8MHz FRC / 2) provided to PLL circuit
   #pragma config POSCMD   = NONE      // Primary osc disabled, using FRC
   #pragma config FSCM     = CSECMD    // Clock switching enabled, fail safe clock monitor disabled
   #pragma config WPDIS    = WPDIS     // Program memory not write protected
   #pragma config WPCFG    = WPCFGDIS  // Config word page of program memory not write protected
   #pragma config IOL1WAY  = OFF       // IOLOCK can be set/cleared as needed with unlock sequence
   #pragma config LS48MHZ  = SYSX2     // Low Speed USB clock divider
   #pragma config WDTCLK   = LPRC      // WDT always uses INTOSC/LPRC oscillator
   #pragma config WDTEN    = ON        // WDT disabled; SWDTEN can control WDT
   #pragma config WINDIS   = WDTSTD    // Normal non-window mode WDT.
   #pragma config VBTBOR   = OFF       // VBAT BOR disabled


Steve
sjg
 
Posts: 3
Joined: Fri Jun 27, 2014 4:47 pm
PIC experience: Professional 1+ years with MCHP products

Re: Difficulty configuring SOSC pins as digital io

Postby jtemples » Tue Jul 01, 2014 8:48 pm

I've run across this in the 87K22 family, in which it's documented a bit more clearly:

"Digital (SCLKI) mode; I/O port functionality of RC0 and RC1 is enabled"

I haven't used the 67J94, but I would assume you need to enable the SCLKI config fuse there as well.
jtemples
Verified identity
 
Posts: 195
Joined: Sun May 25, 2014 2:23 am
Location: The 805
PIC experience: Professional 5+ years with MCHP products

Re: Difficulty configuring SOSC pins as digital io

Postby sjg » Tue Jul 01, 2014 11:51 pm

jtemples wrote:I've run across this in the 87K22 family, in which it's documented a bit more clearly:

"Digital (SCLKI) mode; I/O port functionality of RC0 and RC1 is enabled"

I haven't used the 67J94, but I would assume you need to enable the SCLKI config fuse there as well.


I did wonder about that. But the 67J94 data book has this:
3.9.3 OPERATING MODES
3.9.3.1 Digital Mode
The SOSCO pin can also be configured to operate as a digital clock input. The SOSCO pin is configured as a digital input by setting SOSCSEL (CONFIG2L<3>) = 10. When running in this mode, the SOSCO/SCLKI pin will operate as a digital input to the oscillator section, while the SOSCI pin will function as a port pin. The crystal driving circuit is disabled. The Oscillator Configuration Fuse bits (FOSC<2:0>) and New Oscillator Selection bits (NOSC<2:0>) have no effect.


I had tried it out, though. The data book said the DIG setting should at least allow me to use SOSCI (RC1) as a digital output. I can't.

The data book also says: "The Secondary Oscillator can be turned on by a variety of options:
• SOSCGO – OSCCON2<1>
• SOSCSEL – CONFIG2L<3>
• FOSC<2:0> – CONFIG2L<2:0>
• DSWDTOSC – CONFIG8H<1>
• RTCEN – RTCCON1<7>
• SOSCEN – T1CON<3>, T3CON<3> or T5CON<3>
"

I've ruled out SOSCGO.
Ruled out SOSCSEL and FOSC.
Ruled out DSWDTOSC.
Ruled out SOSCEN.

My hardware guy cannot find any short that would pull these two port pins to ground, but that's where they stay.

I'm stumped.

Steve
sjg
 
Posts: 3
Joined: Fri Jun 27, 2014 4:47 pm
PIC experience: Professional 1+ years with MCHP products

Re: Difficulty configuring SOSC pins as digital io

Postby jtemples » Wed Jul 02, 2014 12:46 am

It's in the errata:

In Table 1-4 on page 20 and Table 11-3 on page
205, RC0 and RC1 are listed as general purpose
I/O pins. Actually, the RC0 and RC1 pins should be
listed as general purpose input pins, with no output
available on those pins.
jtemples
Verified identity
 
Posts: 195
Joined: Sun May 25, 2014 2:23 am
Location: The 805
PIC experience: Professional 5+ years with MCHP products

Re: Difficulty configuring SOSC pins as digital io

Postby sjg » Wed Jul 02, 2014 12:49 am

AARRRGGHHH!!!

I learned a hard lesson a few projects ago about checking the errata. Sadly, I forgot that lesson this time around.

Thanks for doing my own legwork for me (he writes shamefully).

Steve
sjg
 
Posts: 3
Joined: Fri Jun 27, 2014 4:47 pm
PIC experience: Professional 1+ years with MCHP products


Return to 16-Bit Core

Who is online

Users browsing this forum: No registered users and 8 guests

cron