WinPicProg Forums Forum Index WinPicProg Forums
A forum to support WinPicProg
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PIC18F452 interrupts

 
Post new topic   Reply to topic    WinPicProg Forums Forum Index -> Questions
View previous topic :: View next topic  
Author Message
micael



Joined: 31 Jul 2006
Posts: 4

PostPosted: Sat Aug 05, 2006 3:01 am    Post subject: PIC18F452 interrupts Reply with quote

Hi,
Im trying to implement sleep and external interrupts with PIC18F452 but i can't wake up the PIC...

Do i have to use Sleep() in the main function or is enough to use it in #pragma interruptlow low_isr

void main(void)
{
initialise();
while (1) // run forever//
{

{_asm CLRWDT _endasm}

}
}


Complete code:
//ID(821401), PN(1033143), UMO version A19,E48 PNGreen //

#include <p18f452.h>
#include <stdio.h>
#include <delays.h>
#include <timers.h>


/////////////////////////////////////////////////////////////
#pragma interruptlow low_isr
void low_isr (void)
{
if(INTCON3bits.INT1IF == 1) //check for rising edge interrupt at RB1
{

sanity_flasher(Cool; //*flash LED 8 times*/
INTCON3bits.INT1IF=0; //RESET INTERRUPT FLAG!
}
else
{
Sleep(); // go to sleep
}
}
#pragma code


#pragma code low_vector=0x18
void interrupt_at_low_vector(void)
{
_asm GOTO low_isr _endasm
}
#pragma code
//////////////////////////////////////////////////////////////


void sanity_flasher(int flasher) //LED connected at RB1 pin//
{
char c;
c = 1;
while (c<=flasher)
{
if(INTCON3bits.INT1IF == 1) //Turn LED1 OFF (active low)
Delay1KTCYx(1);
LATDbits.LATD7 = 0; //Turn LED1 on (active low)
Delay1KTCYx(1); // delay
c++;
}
}

// main program
void main(void)
{

TRISBbits.TRISB1 = 1; // RB1 Input

TRISDbits.TRISD7 = 0; //RD7 output
INTCON2bits.INTEDG1 = 1; // Rising-edge sensitive
INTCON3bits.INT1IP = 0;
INTCON3bits.INT1IF = 0;
INTCON3bits.INT1IE = 1;
INTCONbits.GIEL = 1;
INTCONbits.GIEH = 1;

while (1) // run forever//
{


{_asm CLRWDT _endasm} // clear the WDT


}

}
Back to top
View user's profile Send private message
Novese



Joined: 16 Aug 2006
Posts: 1
Location: USA

PostPosted: Wed Aug 16, 2006 11:37 pm    Post subject: Reply with quote

To early.
_________________
Community College Tuitions
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    WinPicProg Forums Forum Index -> Questions All times are GMT
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