EB006 with PIC16F88 - won't wake up from sleep

For E-blocks user to discuss using E-blocks and programming for them.

Moderators: Benj, Mods

Post Reply
Phaenix
Posts: 13
Joined: Tue Apr 10, 2012 3:39 pm
Has thanked: 4 times

EB006 with PIC16F88 - won't wake up from sleep

Post by Phaenix »

Code: Select all

void go_sleep(void)
{
	unsigned char oldTRISB, dummy;

	portb = 0;
	porta = 0;

	oldTRISB = trisb;

	trisb = 0xff;

	clear_bit(intcon, GIE);

	set_bit(intcon, RBIE);

	dummy = portb;

	clear_bit(intcon, RBIF);

	sleep();

	nop();

	clear_bit(intcon, RBIF);

	clear_bit(intcon, RBIE);

	set_bit(intcon, GIE);

	trisb = oldTRISB;
}
It'll sleep, but it won't wake up again. What am I doing wrong?

Phaenix
Posts: 13
Joined: Tue Apr 10, 2012 3:39 pm
Has thanked: 4 times

Re: EB006 with PIC16F88 - won't wake up from sleep

Post by Phaenix »

Problem fixed as far as I can tell:

Code: Select all

void pic_lullaby(void)
{
	portb = 0xFF;
	clear_bit(intcon, GIE);
	set_bit(intcon, RBIE);
	clear_bit(intcon, RBIF);
	sleep();
	nop();
	clear_bit(intcon, RBIF);
	clear_bit(intcon, RBIE);
	set_bit(intcon, GIE);
}
If anyone is able to verify that I'm still doing it right, that would be great.

Post Reply