this is my code example it works great, i put pic to sleep sinding 1919 and i wake up pic when i send any number ,using serial communicator in mcode studio.
Code:
'pic16f628a
@ DEVICE WDT_ON, PWRT_OFF,MCLR_ON,CPD_OFF, BOD_OFF, PROTECT_OFF,INTRC_OSC_NOCLKOUT
Include "modedefs.bas"
PCON.3=1
DEFINE OSC 4
RCSTA=$90'DEFINE HSER_RCSTA 90H
TXSTA = $20'DEFINE HSER_TXSTA 20h
DEFINE HSER_BAUD 2400
DEFINE HSER_SPBRG 25
'DEFINE HSER_EVEN 1
DEFINE HSER_CLROERR 1 ' Clear overflow automatically
'DEFINE HSER_TIMEOUT 1 ' Clear overflow automatically
define RX_INT PIR1,RCIF ;-- USART Receive Interrupt
PORTA = %00000
PORTB = %00000011
TRISA = %00000
TRISB = %00000011
intcon = 0
vrcon = 0
CMCON = 7
SDO Var PortB.4
SCLK Var PortB.5
BTM Var PortB.6
BTN VAR PORTB.7
SEG var byte
Digit var byte[4]
index var byte
B0 var word
D0 var byte
j var BYTE
b0 = 0
LOOP:
if B0 = 1919 then SLP
HSERIN 10,main,[DEC4 b0]
MAIN:
'im using here dsr 7segment leds with 74hc164 , bcz not found lcds in my country no pic ic
D0 = B0 DIG 0
READ D0,DIGIT[0]
D0 = B0 DIG 1
READ D0,DIGIT[1]
D0 = B0 DIG 2
READ D0,DIGIT[2]
D0 = B0 DIG 3
READ D0,DIGIT[3]
for index = 0 to 3
seg = digit [index]
SHIFTOUT SDO,SCLK,0,[SEG\8]
PORTA.0[index] = 1
PAUSEus 999
PORTA=0
NEXT INDEX
goto loop
SLP:
CLEAR
PORTB = %00000011 ,,, tried portb.0 with rx port ising led ot IR ld .
OPTION_REG = %00000001
pause 100
INTCON.1 = 0
INTCON.4 = 1
@ SLEEP
@ NOP
B0 = 0000
PAUSE 100
HIGH PORTB.7 ' just to see pic is wake up
PAUSE 1000
LOW PORTB.7
GOTO LOOP
END
data @0,3,159,37,13,153,73,65,31,1,9 'here s the numbers from 0 to 9
thanks a lots for helping
Bookmarks