Dual Speed Operation

Discuss PIC and electronic related things

Moderators: David Barker, Jerry Messina

Post Reply
animo3d
Posts: 24
Joined: Sun Sep 18, 2011 6:02 am
Location: Monterrey Mexico

Dual Speed Operation

Post by animo3d » Sun Dec 15, 2013 8:56 am

Hello, I'm developing a gadget for a client that is a simple data logger it has a connector with a serial port and Voltage for logging, and another connector with USB for dumping the data to the PC.

So you plug the device on the client equipment with the serial por connector and the logger detects the connection and starts logging...
then the user manually removes the device (that looks like a bulky usb pen) and plugs it using the usb connector on the PC to dump the data...

Im using a 18f27J53 with an external flash memory, and everything works fine...

the problem is that the current on the client equipment is very limited (battery operated), so I would like to run the PIC at a lower speed, say 4 mhz, to save some milliamps when is connected to the serial port and run at 48 when is connected to the USB.

I have spare input pins that i can use recognize which end is connected to set the speed...

the question is if this is possible..???

is possible to use a config when an input is up at startup and another config when is down???

also is the clock keyword resettable or usable within an if?

help will be appreciated...

thanks in advance
Sergio

Jerry Messina
Swordfish Developer
Posts: 1469
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: Dual Speed Operation

Post by Jerry Messina » Sun Dec 15, 2013 4:46 pm

>the question is if this is possible..???

It's very possible. The J53 has quite a number of power-saving modes and osc configurations available.
There's a number of chapters in the data sheet regarding this. I'd suggest reading over those sections
a few times since the options can be very confusing (and there's a LOT of them).


>is possible to use a config when an input is up at startup and another config when is down???

You can't change the CONFIG settings on a running part, but you can use the OSCCON register to
select between a number of settings.

While I've seen folks use the INTOSC to run the USB, it's only spec'd to work for low-speed USB. You could
use an ext xtal for USB operation, and switch to INTOSC when using the UART.


>also is the clock keyword resettable or usable within an if?

No. You can use '#if (_clock = xx)' at compile time, but for runtime changes you'll
have to keep track of the current clock setting yourself.

You may have to make manual adjustments to any delays and peripheral settings such as the UART
baud rate as you change clock settings since most of these rely on the compile-time
'clock=' setting to be correct.

Post Reply