View previous topic :: View next topic |
Author |
Message |
E_Blue
Joined: 13 Apr 2011 Posts: 417
|
TMR1 OSC with external 32768KHz XTAL not clocking CPU |
Posted: Fri Dec 23, 2011 8:13 am |
|
|
I'm working on a low power device that needs to sleep(at main()) and wake up one time per second to flash a LED, from a low priority interrupt routine, until a button is pressed for at least 3 seconds.
The device implements a USB CDC port, so it have a primary 8MHz Xtal and start with that Xtal; the problem appears when I change the main system OSC to the secondary TMR1 low power OSC.
So when the processor start...
OSCTUNE=0b01000000(PLL on)
OSCCON=0b11110100(48MHz from PLL/Idle on SLEEP)
CCPR1=32768
ECCP1CON=0b1011
TIMER1=0b00001011
TIMER3=0b10001010
PIE1=0x00100100
Before the sleep instruction I call a subroutine that shut off some pins and clear some variables and change the clock source to the low power oscillator in order to reduce the power needs, or at least that's the idea.
So I change the OSCCON value
OSCCON=0x81 <-- At this point the processor halts!
If I change OSCCON value to 0xF3(INTRC 8MHZ) It works ok and ; Why?
I already test the low power TMR1 OSC and runs OK. Did I forgot something or can be some bug on the core?I'm working on a low power device that needs to sleep and wake up one time per second to flash a LED, from a low priority interrupt routine, until a button is pressed for at least 3 seconds. _________________ Electric Blue
Last edited by E_Blue on Fri Dec 23, 2011 8:56 am; edited 1 time in total |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19546
|
|
Posted: Fri Dec 23, 2011 8:54 am |
|
|
1) What processor.
2) Use the CCS functions. |
|
|
E_Blue
Joined: 13 Apr 2011 Posts: 417
|
|
Posted: Fri Dec 23, 2011 9:04 am |
|
|
The processor its a PIC18F67J50 in TQFP package.
I already tried with CCS functions and simply by defining them as #Byte but none works.
I Also use sleep() and sleep(SLEEP_IDLE), same results.
I don't put the code because is too big more than 150Kbytes of C code, it haves about one year of work on it, so I just tried to summarize the code. _________________ Electric Blue |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Fri Dec 23, 2011 10:08 am |
|
|
Cut a small , compilable program that shows us the problem( <20 lines of code),as well as PIC type and Compiler version. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19546
|
|
Posted: Fri Dec 23, 2011 10:50 am |
|
|
I don't think what you want is possible.
There is a problem with putting a device to sleep with a low speed clock,if it implements USB.
Thing is that a slave device _must_ respond to interrupts from the USB master. The USB master can 'ask' a device to sleep, and it can then sleep, but must re-awaken on the USB 'ACTVIF' interrupt. This requires that the USB circuitry is put into 'suspend' mode (not sleep), and the master clock for USB must still run. Power in this mode is just under 500uA, and is the lowest power mode you can put a USB running device into. The USB master warrants that it can deliver 500uA, to devices that are in suspend mode.
So I'd say it is physically not possible on the chip if you have the USB peripheral enabled.
Best Wishes |
|
|
E_Blue
Joined: 13 Apr 2011 Posts: 417
|
|
Posted: Fri Dec 23, 2011 11:18 am |
|
|
Ttelmah I know that, and the program have routines in order to don't allow to go to sleep mode when USB is running; the circuitry have is own dual power supply, battery and external 12VDC, and the idea is to let the user power off the device in order to store the device until it is sold(this is one of the power modes), the second one is IDLE mode, since is operative but no all functions are running, just a couple of software timers and input checks.
When one of the software timers make an overflow the device wake up, start the main OSC and the PLL in order to run more complex tasks.
temtronic, that´s is a complex task at this moment cause I need to show some results to my boss today, so ill keep trying, but if none work I'll be back with the small code.
Thanks. _________________ Electric Blue |
|
|
|