|
|
View previous topic :: View next topic |
Author |
Message |
[email protected]
Joined: 10 Nov 2012 Posts: 19
|
wake up from sleep by timer1 in SSOP package |
Posted: Fri Apr 19, 2013 11:20 pm |
|
|
Hi every one, I am really confused, Because I have tried to wake up the PIC18F24K22 by timer1 interruption , actually I did it via DIP28 Package on bread board but when I struggled to run the same program by SSOP28 package, It did not work whereas it had been expected it should have worked much better because of reduction of noise and SMD installation, I am sure that there is no problem in coding, because if there was any problem, it must have not run on the DIP28 package.
beside, I am sure that timer 1 Oscillator is being enabled when I am using SSOP package, due to the fact that while I touch the SOSC1 (pin 11 ) it wakes up.
I have posted the code as following. the program has been written via PCWHD ver. 4.130
finally I have to mention that all conditions and value of components are the same ( the capacitors of oscillator driver are chosen 22pf and the crystal is 32.768 Khz), more over I soldered the crystal directly to the correspond pins without any distance)
Please give me some advice ...
who knows the problem?
Code: |
#include <18F24K22.h>
#device adc=16
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES INTRC_IO //High speed Osc, medium power 4MHz-16MHz
#FUSES NOPLLEN //4X HW PLL disabled, 4X PLL enabled in software
#FUSES NOBROWNOUT //No brownout reset
#FUSES WDT_NOSLEEP //Watch Dog Timer, disabled during SLEEP
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#use delay(clock=8000000)
#define LED PIN_B4
#define DELAY 10
#INT_TIMER1 NOCLEAR
void TIMER1_isr(void)
{
clear_interrupt(INT_TIMER1);
output_toggle(LED);
// sleep();
}
void main() {
int level,m;
setup_timer_1(T1_EXTERNAL|T1_DIV_BY_1|T1_ENABLE_SOSC);
// enable_interrupts(INT_EXT);
clear_interrupt(INT_TIMER1);
enable_interrupts(INT_TIMER1);
enable_interrupts(GLOBAL);
while(1)
{
set_timer1(65506);
sleep();
} |
|
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Sat Apr 20, 2013 1:41 am |
|
|
I assume you're seeing no activity at all.
In that case why not make sure the system is running BEFORE sending to sleep.
i.e. do a few timed toggles of the LED first. Then you will know that it's running, and at the correct speed.
Mike
EDIT Runs in my mind you've had low frequency crystal problems before. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19499
|
|
Posted: Sat Apr 20, 2013 2:04 am |
|
|
sleep(SLEEP_IDLE);
The default 'sleep', turns off _everything_.
Best Wishes |
|
|
[email protected]
Joined: 10 Nov 2012 Posts: 19
|
Mike |
Posted: Sat Apr 20, 2013 2:10 am |
|
|
Hi Mike,
Thanks for your reply.
But, I have tested the system with many other programs, such as sleep and waking up by external interrupt, and it works fine. But in this case it does not work..., Yes, you are right I have had some problem about running PIC at low frequency. What do you think about the PICs, because I bought four of them from element14 company... I do not know ... Really I am confused.
Best regard
I am expecting for your advice or any guidance. |
|
|
[email protected]
Joined: 10 Nov 2012 Posts: 19
|
Ttelmah |
Posted: Sat Apr 20, 2013 2:17 am |
|
|
Hi Sir,
I do not think so, Because, Firstly in my compiler this instruction does not exist, secondly, the system is working well in DIP28 package... and also other program as I already mentioned in my latest post, are being run perfectly...
Best Regards, |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Sat Apr 20, 2013 2:40 am |
|
|
This line makes me think you've got a hardware issue.
Quote: | beside, I am sure that timer 1 Oscillator is being enabled when I am using SSOP package, due to the fact that while I touch the SOSC1 (pin 11 ) it wakes up. |
When you touch the SOSC1 pin it's possible you're giving it a kick up its **** and starting it up!
In other words you're still possibly marginal on getting low frequency oscillators working reliably.
I don't have your PIC and haven't used watch crytals for some time.
I do remember, from the days of using dedicted time-kepping peripheral chips, they were fussy.
OK, different chips, but the physics of making a crystal work @ ~30kHz is still the same.
Even waving a 'scope probe close to one could produce strange effects.
Mike |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19499
|
|
Posted: Sat Apr 20, 2013 2:43 am |
|
|
Full sleep _will_ stop the timer oscillator.
It'll do the same on a DIP28 package, if the rest of the hardware, chip version, and the code is the same.
External interrupts will work, since they do not rely on a clock still running.
The code as posted won't compile, which doesn't give confidence...
To generate sleep idle mode, if your compiler has not got it, use:
Code: |
#bit IDLEN=getenv("BIT:IDLEN")
//Then to sleep use
IDLEN=TRUE;
sleep();
|
|
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Sat Apr 20, 2013 2:56 am |
|
|
I'd go with whatever Ttelmah advises.
He's usually spot on.
Mike |
|
|
[email protected]
Joined: 10 Nov 2012 Posts: 19
|
Dear Ttelmah and Mike |
Posted: Sat Apr 20, 2013 3:48 am |
|
|
Thank you so much for your advices ....
Dear Ttelmah I added the exact lines as you had suggested but still it is not running... I forgot to tell you that I have pull down all three external interrupts to prevent of any effects or triggering coming from external interrupt... if the picture of the circuit or program could help to solve the problem I will post it...
the program that I compile is :
Code: | #include <18F24K22.h>
#device adc=16
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES INTRC_IO //High speed Osc, medium power 4MHz-16MHz
#FUSES NOPLLEN //4X HW PLL disabled, 4X PLL enabled in software
#FUSES NOBROWNOUT //No brownout reset
#FUSES WDT_NOSLEEP //Watch Dog Timer, disabled during SLEEP
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#use delay(clock=8000000)
#define LED PIN_B4
#define DELAY 10
#bit IDLEN=getenv("BIT:IDLEN")
#INT_TIMER1 NOCLEAR
void TIMER1_isr(void)
{
clear_interrupt(INT_TIMER1);
output_toggle(LED);
}
void main() {
int level,m;
setup_timer_1(T1_EXTERNAL|T1_DIV_BY_1|T1_ENABLE_SOSC);
clear_interrupt(INT_TIMER1);
enable_interrupts(INT_TIMER1);
enable_interrupts(GLOBAL);
while(1)
{
set_timer1(65506);
//Then to sleep use
IDLEN=TRUE;
sleep();
}
|
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Sat Apr 20, 2013 5:31 am |
|
|
well, you've got a head scratcher! If everything is the same,code and components) except for the PIC package, I'd say it's a phyisical problem.
Maybe 'gunk' on the PCB, under the SMT ?
I'm with Mike with having a 'power on-ready-to-go LED' as a confirmation 'I'm OK'.
I have to ask,why use the SMT package instead of DIP?Is there any real cost savings?(parts AND manhours)I know it might be 1/2 the size...but I'm curious.
Seems a shame the amount of time spent on debugging this head scratcher!
jay |
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1345
|
|
Posted: Sat Apr 20, 2013 6:23 am |
|
|
Ttelmah wrote: | Full sleep _will_ stop the timer oscillator.
It'll do the same on a DIP28 package, if the rest of the hardware, chip version, and the code is the same.
External interrupts will work, since they do not rely on a clock still running.
|
What is your interpretation of sections 12.4 and 12.5 of the data sheet which indicate it would still run during sleep? I ask this because I actually use Timer 1 to wake from full sleep on a number of other chips (all PIC24s so they are different chips) using an external 32kHz crystal. I am not familiar with this specific chip, mind you.
The text in those sections seems in direct opposition to some of the text in the power management modes section, but it jives with my own personal history (again, on different chips though). |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19499
|
|
Posted: Sat Apr 20, 2013 2:53 pm |
|
|
It depends on the chip. On this one, Timer1, will still count, but all oscillators stop. It is different on chips where this is not the 'secondary oscillator'.
I think he needs to ensure that the two SCS bits are set to '10', to give the secondary oscillator still running. On the current compiler this is done for you if you select the IDLE mode, which he doesn't have.
Table 3-1, is the 'key' one. With the first line showing 'all clocks stopped' in full sleep mode.
With IDLEN set to 1, what happens depends on the SCS bits. I'd suspect the default is 00, which leaves the main oscillator running, but the secondary still stops, or 11, which leaves the internal RC oscillator running, but the other oscillators off. Only 10, gives the secondary left running.
It may be that a mask difference, is meaning that the default value for the SCS bits change. Hence the chip version number comment, and the difference seen.
So:
Code: |
#byte OSCCON=getenv("SFR:OSCCON")
#bit IDLEN=getenv("BIT:IDLEN")
OSCCON=(OSCCON & 0xFC) | 2; //Set SCS bits to 10
IDLEN=TRUE;
sleep();
|
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|