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

PIC18F doesn't wake up by ECCP1

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



Joined: 13 Apr 2011
Posts: 417

View user's profile Send private message

PIC18F doesn't wake up by ECCP1
PostPosted: Wed Jun 01, 2016 9:11 am     Reply with quote

I'm trying to make a code for a delay that put the µC in to sleep mode while is waiting for CCP1 event but I can get that the CCP1IF flag get set.

Is something very basic, I don't understand what I'm doing wrong.

Code:
void delay_1msSL(long timeX)
{
   if(timeX>2047)
   {
      timeX=2047;
   }
      
   if(!TMR1ON)
   {
      SETUP_TIMER_1(0b10001111);//Crystal 32.768KHz     
   }
   IDLEN=1;//Idle mode - Only peripherals run
   DISABLE_INTERRUPTS(GLOBAL);
   //CCP1
   CCP_1=32*timeX;
   SETUP_CCP1(CCP_COMPARE_INT);
   CLEAR_INTERRUPT(INT_CCP1);
   ENABLE_INTERRUPTS(INT_CCP1);
   
   do{
   #asm
   sleep
   #endasm   
   }while(!interrupt_active(INT_CCP1));
   
   CLEAR_INTERRUPT(INT_CCP1);
}


Another doubt is If the GLOBAL interrupt enable bit is disabled, and the CCP1 flag is set, the µC will wake up?

The µC is a PIC18F67J50
_________________
Electric Blue
E_Blue



Joined: 13 Apr 2011
Posts: 417

View user's profile Send private message

PostPosted: Wed Jun 01, 2016 11:41 am     Reply with quote

Solved, the problem was that the TMR1 was not in synchronized mode, now works like a charm.
_________________
Electric Blue
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