Timer1 oscillator continues to run during sleep mode, but ... try it like this.
First, comment all the OSCCON and OSCTUNE statements you showed above.
Then ...
Code:StandAloneLoop: ASM SLEEP NOP NOP ENDASM GOTO StandAloneLoop
Timer1 oscillator continues to run during sleep mode, but ... try it like this.
First, comment all the OSCCON and OSCTUNE statements you showed above.
Then ...
Code:StandAloneLoop: ASM SLEEP NOP NOP ENDASM GOTO StandAloneLoop
DT
Tried this step by step.
Commenting either or all of these:
stop operation. However I'm not sure if it's because the interrupt is not triggered anymore or if that's because the CPU does not come back from sleep. I remember reading that Timer1 oscillator was always running, but looking carefully at the datasheet again I cannot find that statement back. Only mention is that SLEEP (not IDLE) mode turn off all clocks and all oscillators, expect for the WDT oscillator (if enabled).Code:OSCCON.1 = 0 OSCCON.0 = 1 'Use Timer1 oscillator as clock source OSCCON.7 = 1 'Device enters in IDLE mode when sleep instruction issued
And you had more statements than those 3.
One of them disables the Primary Oscillator, which will keep it from running after it wakes up I would assume.
DT
Yes but I commented all others as well. I just quoted the lines that caused the interrupt to stop working.
I want to disable the primary oscillator, because I have 2 operating modes:
1) USB attached, clocked from a 12Mhz ceramic resonator, with PLL enabled and CPU clocked at 48Mhz
2) USB detached, standalone, CPU and peripherial clocked from Timer1 secondary oscillator.
When the CPU wakes from sleep it should resume on the oscillator defined by the SCS bits, here SEC_RUN mode:
Code:OSCCON.1 = 0 OSCCON.0 = 1 'Use Timer1 oscillator as clock source
Now you found that statement back from the datasheet, there's hope to make it work! I'll investigate harder and make some tests on a simplified program.
I realized that I have a very strange problem when I write to my I2C EEPROM when the CPU is clocked at 32.768kHz, I get corrupted data if there's a long chain of "0" being sent.
I record my temperature samples two by two, and they span 3 bytes in memory (Byte A, B and C). One sample is 12bit, 8 bit for integer value (Sign + 7 bit value), and 4 bits for decimal value (0.0625 steps). They are recoded with an interleave routine as such:
Sample 1 : AAAAAAAA.BBBB
Sample 2 : BBBBCCCC.CCCC
I have a 5ms pause between the 3 write operations, and there's about 20 sec between the record of each packets of 3 bytes. I tried increasing the write delay to 20ms without changes, and EEPROM VCC is within range.1811 2010/10/29 0h44m00s +23.9375
1812 2010/10/29 0h44m10s +23.9375
1813 2010/10/29 0h44m20s +24.0000
1814 2010/10/29 0h44m30s -7.9375
1815 2010/10/29 0h44m40s +24.0000
1816 2010/10/29 0h44m50s -7.9375
1817 2010/10/29 0h45m00s +24.0000
1818 2010/10/29 0h45m10s -8.0000
1819 2010/10/29 0h45m20s +23.9375
1820 2010/10/29 0h45m30s +23.9375
This occurs when odd samples ends with .0000, .2500, .5000, and .7500, the problem does not appears if I run the CPU using the internal oscillator at 250kHz (and readjusting all the delay values accordingly), which makes me wonder if I2CWRITE can be used with a CPU clock of 32.768kHz...
Also, this might be related to the issue I have... is doing such operation:
modify the original value of TempH?Code:DataValue = TempH >> 4
The logger project is getting near completion! I am now into the autonomous mode power, and I was able to measure these figures while powering the device from a battery across a 10 ohm shunt.
It is quite clear that I have to improve power consumption as at 900µA the 130mAh battery runs for about 6 days... The PIC sits most of the time at IDLE, and here it shows where a second sample is read and written to memory with the first previously read sample (hence the 3 write cycles for 2x 12bits).
I have not managed yet to make the true sleep mode to work, but at IDLE the power consumption seems to be very high... there's no difference than when running the CPU from internal clock at 250kHz. As I said above I tried running the CPU from Timer1 oscillator but that gave me some memory writing issue so I quitted.
Other than the PIC eating power I have (when IDLE):
LDO regulator, 500nA
I2C EEPROM, 1µA
I2C Temperature sensor, 1µA
220k/220k voltage divider, 5µA
Will try to investigate more and post results![]()
Maybe you can control EEPROM and Temp. Sensor power by a pin from your controller. When you have to make new measurements, just make the pin high, wait a little to let the circuit settle, and do your sampling and writing. Then switch them off again.
Ioannis
Bookmarks