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

Timer1 as external - External interrupt trouble

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



Joined: 11 May 2006
Posts: 78

View user's profile Send private message

Timer1 as external - External interrupt trouble
PostPosted: Tue Sep 25, 2007 6:02 am     Reply with quote

PIC:- 16F688
Compiler:- 3.249

Hello,
I have managed to set up timer1 as an external timer so that I can put the PIC to sleep and wake up with a 32kHz crystal.

I also would like to be able to use the external interrupt to wake the PIC up from sleep.

Basically when I enable the Gloabl Interrupt the PIC no longer wakes from sleep. I have not set the Global Interrupt bit as I am using the Int Peripheral Bit for the timer1 module.

Does anyone know what may cause the interrupt to stop woking when I put it to sleep?

Only snippets of code:-
Code:

#define INT_PERIPEHRAL  0x0B40
.
.
.
#int_EXT
ext_isr()
{
    delay_ms(100);
    external_int ++;
}
.
.
void goto_sleep()
{
    .
    .
    .
    set_timer1(0);
    clear_interrupt(int_timer1);
    enable_interrupts(int_timer1);
   
    //adding
    //enable_interrupt(int_ext);
    //enable_interrupt(global);
    //here stops the PIC from waking

    sleep();

    nop();

    clear_interrupt(int_timer1);
    disable_interrupts(int_timer1);
    .
    .
    .
}

void main()
{
    setup_timer1(T1_external | T1_div_by_4 | T1_clk_out);
    set_timer1(0);
    enable_interrupts(int_timer1);
    enable_interrupts(int_peripheral);
.
.
.
    while(1)
    {
        goto_sleep();
        .
        .
    }
}
[/i]
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue Sep 25, 2007 6:33 am     Reply with quote

Setting the global interrupt flag means you will have to add a timer1 interrupt handler as well or the timer1 flag will never get cleared and your PIC hangs.
sjharris



Joined: 11 May 2006
Posts: 78

View user's profile Send private message

Thanks
PostPosted: Tue Sep 25, 2007 7:01 am     Reply with quote

I just found that out!!

Thanks for reply. It is (fingers crossed) working now!!
Steve
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