Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

CC5X, PIC16F631 and Interrupt

Status
Not open for further replies.

Nayth

New Member
Hi all

I'm trying to program a PIC16F631 and I need to wake up the pic from a sleep. This should be done from a PIN change (Interrupt), but I can't get it to work.

I have 2 Ports, when both Ports are HIGH the PIC goes to sleep. What I need the PIC to do is wake up if either of the 2 PORTS are HIGH for more than 3 seconds.

I tried setting RABIE to 0 and then setting it to 1 just before I call sleep, but this does not work.

I set GIE to 1 when i initialize the program.

I've also tried the #pragma origin 4 thing but CC5X complains and gives me this error.
Code:
Overlapping code
 (The pointer to the next free location in each code page can not be
 moved backwards (only forwards). This also applies if locations was
 skipped by an earlier #pragma origin statement)

So, what I was hoping was that one of you guys could point me in the right direction and tell me what's wrong
 
If this is a wakeup on pin change interrupt then you need to read all ports that can cause an interrupt before going to sleep.

Mike.
 
I can't seem to find any info on doing so.

Could you give me an example?

PORTA.0 and PORTA.1 are the ones I need to check for pin change

I've set both IOCA.0 and IOCA.1 to 1 which should be the same as IOCA = 0b000011 if I'm not mistaken
 
This

I've also tried the #pragma origin 4 thing but CC5X complains and gives me this error.

suggests that you haven't actually been able to set up an interrupt handler at all. You should look in the CC5X manual, which gives an example of how to set up an interrupt handler.

Here is a simple example of how to set up an interrupt handler in CC5X:
(this is for Timer0). You can't have any code before the interrupt handler

Code:
#include "int16CXX.H"

//Interrupt Handler
//=================================================
#pragma origin 4
interrupt serverX( void)
{
    int_save_registers
// TMR0 Interrupt Handler
    if ( T0IF && T0IE ) {
        T0IF = 0;
	++runningTime;
    }


    int_restore_registers 
}

// mainline code follows

void main(void) 
{
// main code here
}

Mike
 
Thanks for the help

Turns out I had some code before my origin statement and that was the problem. Shifted the code around and now it works.

Thanks again :D
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top