PIC16F1936, PBP PRO 2.60, MPASM,
My Slave Board receives com from the Master Board and runs Subroutines.
Slave operates in tight loop at Start.
On EUSART INT Slave receives one command Byte from Master and advances to CaseAction (Multi-IF THENs) which will branch to Sub to take action.
When Slave receives a code for Sleep Mode (CASE 7) is run.
Here’s where my problems start!
It seams that the RCIDL bit is never being set after Rx.
Will not go into SLEEP mode with or without -
BTFSS BAUDCON,RCIDL ;Check for High, no receive in progress
GOTO $-1
Before WUE bit is set.
What would prevent RCIDL from being set? Even after a hundred cycles after Comm is complete? Data Sheet says this bit should be set on EUSART Stop bit. At this time no Rx is coming from the Master. Can’t get any SLEEP!
Wayne
Code:
Start:
@ nop
@ BTFSS _INTbit ;if set - gosub CaseAction
@ goto $-1
INTbit=0 ‘My INT flag bit
gosub CaseAction
goto Start
;----------------------------------------------------------------------------------
RXceiveINT: ‘ISR
INTbit=1 'Set INTbit to break out of Start loop
hserin [Bvar]
@ INT_RETURN ;goes back to INTerrupt locaion. which is Start loop.
;----------------------------------------------------------------------------------
CaseAction: ‘PBP multi IF THEN’s
busy=1
@ MOVF BAUDCON,0 ;What is in the RCIDL bit? ;TESTING
@ MOVWF _Avar ;TESTING
serout2 USB_Tx,84, [" BAUDCON=",bin8 Avar,13,10] ;TESTING
Bvar=Bvar+1 'On wakeup Slave receives %00000000 from Master,
Select Case Bvar
Case 1 ;No action taken if Not in Sleep Mode
gosub Dummy
;------------
CASE 7
gosub SleepMode
end select
busy=0
return
;----------------------------------------------------------------------------------
;------------------Case7
SleepMode:
@ INT_DISABLE RX_INT ‘ASM- disable EUSART interrupt
PortA.1=1 ‘Flash LED when entering Sleep Mode routine
pause 100
PortA.1=0
@ MOVF BAUDCON,0 ‘Is RCIDL idel? Set for Idel ‘For testing
@ MOVWF _Avar ‘For testing
Avar=Avar dig 6 ‘For testing
serout2 USB_Tx,84, [" RCIDL=",dec Avar,13,10] ‘display contents of RCIDL ‘For testing
ASM
BSF BAUDCON, ABDEN ;enable Auto Detect in sleep mode - tried with and without
BTFSS BAUDCON,RCIDL ;Check for High, no receive in progress - tried with and without
GOTO $-1 ;return to previous line
BSF BAUDCON,WUE ;Set to Wake on Rx from Master
SLEEP
nop ‘WAKE from EUSART Rx should occur here
nop
nop ;
ENDASM
for Avar = 1 to 10 ‘flash LED on wakeup for TESTNG
PortA.3=1
pause 50
PortA.3=0
pause 50
next Avar
@ INT_ENABLE RX_INT ‘ASM- reenter EUSART interrupt
Return
END
Bookmarks