![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
picnic
Joined: 09 Oct 2008 Posts: 15
|
Help with 18F46K22 not exiting sleep on TIMER1 overflow |
Posted: Wed Jan 04, 2012 5:53 am |
|
|
I'm trying to use a single rising edge on TIMER1 (RC0) to trigger a TIMER1 overflow interrupt and to wake the PIC from sleep. The code below works as I'd expect on a 16F887 (different include and fuses) but not on the 18F46K22. In this later case I can see the ISR being called at the appropriate time using an oscilloscope but the PIC doesn't exit sleep and I don't understand why
Code: |
#include <18F46K22.h>
#DEVICE ADC=10
#fuses INTRC_IO // Use Internal OSC
#fuses WDT1024 // 1024 * 4ms = ~4 sec
#fuses NOMCLR
#fuses NOPROTECT // Protect Programm Memory
#fuses NOCPD // Protect Data EEPROM
#fuses NOBROWNOUT
#fuses NOFCMEN
#fuses IESO
#fuses TIMER3C0
#fuses CCP2C0
#use delay(clock=4000000)
#use rs232(baud=19200, UART1, STREAM=SerialUI, errors )
#int_timer1
void isr_timer1() {
set_timer1( 0xffff );
output_toggle( PIN_E1 );
}
void main() {
printf( "Hello World\r\n" );
output_high( PIN_E0 );
output_high( PIN_E1 );
output_drive( PIN_E0 );
output_drive( PIN_E1 );
setup_timer_1( T1_EXTERNAL | T1_DIV_BY_1 );
set_timer1( 0xffff );
enable_interrupts(INT_TIMER1);
enable_interrupts(GLOBAL);
while( 1 ) {
sleep() ;
restart_wdt();
output_toggle( PIN_E0 );
}
} |
Any clues gratefully received, thank you for your time |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9178 Location: Greensville,Ontario
|
|
Posted: Wed Jan 04, 2012 8:42 am |
|
|
Could be a compiler 'bug'..
I'd look at the listing and compare to the one that works.
I'm curious as to what 'output_drive()' does ! |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19384
|
|
Posted: Wed Jan 04, 2012 9:57 am |
|
|
Output_drive sets the TRIS on the selected bit to '0'. Does nothing in this code, since the tris for each of the bits it is used on, has already been set to '0' by the previous output_high instruction. Only really meant to be used if you have used output_float to turn off the drive on a bit....
Obvious first things that might cause a problem, are TIMER3C0, and CCP2C0. The first puts timer3 on the C0 pin, and the second CCP2 as an output also on this pin However timer1, should still be on this pin. The second big difference with this chip though, is the presence of the gate control on timer1. Though this should be off by default, it is possible that the compiler is not disabling it. Perhaps worth trying defining the bits TMR1ON, and TMR1GE, and trying enabling the first and disabling the second.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|