|
|
View previous topic :: View next topic |
Author |
Message |
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
LCD Inop After Sleep |
Posted: Sat Apr 29, 2006 4:01 pm |
|
|
Hello All,
18F4620
3.236
I've got a character LCD connected to port_d and I'm using the standard lcd.c driver. When I put the PIC to sleep the LCD won't work upon wake-up. I init it and do everything just like upon power up.
However, if I reset_cpu() I can get the LCD to work, but that generates another problem. I use a momentary switch to interrupt RB6 to wake the processor. When I push the button to wake the CPU, the interrupt 'hangs' i.e. fires continuously.
If I disable the portb interrupts in the ISR the interrupt no longer 'hangs', but I can never get the portb interupt re-enabled....
Any ideas?
Thanks,
John |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Apr 29, 2006 11:03 pm |
|
|
The test program shown below works OK. I tested it on a PicDem2-Plus,
which has the LCD on pins D0-D3 and A1-A3. To get the INT_RB
interrupt, I pulled out the ICD2 connector and jumpered the push-button
switch on B0 over to pin B7. When it's in Sleep mode, I push the
button and it displays this on the LCD:
Quote: |
Wake up
Hello World
Sleeping
|
I can do that repeatedly.
Code: |
#include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
#include "flex_lcd.c"
#int_rb
void rb_isr(void)
{
disable_interrupts(INT_RB);
}
//======================================
void main()
{
int8 i;
int8 c;
lcd_init();
port_b_pullups(TRUE);
while(1)
{
lcd_putc("\fHello World");
delay_ms(2000);
c = input_b(); // Clear "change condition" on Port B
clear_interrupt(INT_RB); // Clear RBIF flag
enable_interrupts(INT_RB); // Enable RB interrupts
enable_interrupts(GLOBAL);
lcd_putc("\fSleeping");
sleep();
lcd_putc("\fWake up");
delay_ms(2000);
}
} |
|
|
|
|
|
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
|