CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Help with 18F46K22 not exiting sleep on TIMER1 overflow

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
picnic



Joined: 09 Oct 2008
Posts: 15

View user's profile Send private message

Help with 18F46K22 not exiting sleep on TIMER1 overflow
PostPosted: Wed Jan 04, 2012 5:53 am     Reply with quote

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 Confused

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
temtronic



Joined: 01 Jul 2010
Posts: 9241
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Jan 04, 2012 8:42 am     Reply with quote

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 !
Ttelmah



Joined: 11 Mar 2010
Posts: 19535

View user's profile Send private message

PostPosted: Wed Jan 04, 2012 9:57 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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