PDA

View Full Version : Asm sleep - pbp sleep



MOUNTAIN747
- 4th May 2020, 23:06
My project uses a 16F1936 on both a Master and a Slave board. Durring the program the Master sends a code for the Slave to run a subroutine to SLEEP. I am trying to use ASM SLEEP as to NOT designate a time to wake. twenty two hours after the slave enters sleep it recieves a USART comm which should WAKE the slave from SLEEP. Problem is the slave is not going to sleep, or it wakes right away after the command. So, how to trouble shoot SLEEP? I can't monitor the STATUS, PD bit while in sleep, I can only use an indicator LED when going into the SLEEP instruction and toggle it off when exit the sleep instruction, and it is toggling right away.
One observation is that PBP asks for a period whenever I type SLEEP in the ASM module. Can PBP tell the difference between ASM SLEEP and PBP SLEEP or are they both seen as a PBP command? Comments please.

;Slave Board
PortA.1=1 Indicator LED

RXceiveINT:
INTbit=1 'Set Cvar to break out of Start loop
Com_Enable=0 ' Con_enable not needed to RX
hserin [Bvar]
@ INT_RETURN ;goes back to INTerrupt locaion. which is Start loop.

;-----------------------
CaseAction:
busy=1
Select Case Bvar
Case 0 ;No action taken if Not in Sleep Mode, Return only
@ nop ;If in Sleep Mode, Wake up, goto Start
@ nop
@ nop
Case 1
gosub Ran_num
Case 2
gosub RappidFireRight
case 3
gosub RappidFireLeft
case 4
gosub Desolve
case 5
gosub FlashFlies
CASE 6
gosub SleepMode ;subroutine to place Slave in Sleep mode
end select
busy=0
return

;------------------Case6
SleepMode:
PortA.1=0 ;Indicator LED out on entering SLEEP
ASM
BTFSS BAUDCON,RCIDL ;Check for High, no receive in progress
GOTO $-1
BSF BAUDCON,WUE ;Wake on Rx from Master
SLEEP
nop
nop
nop
ENDASM
PortA.1=1 ;Indicator LED ON at exit SLEEP
return
end

The Master does not use the comm line for the next 22 hours.

Wayne

mpgmike
- 5th May 2020, 02:30
@ SLEEP
@ NOP

It often makes a difference adding the NOP right after SLEEP.

richard
- 5th May 2020, 03:41
at a guess is it possible there is still activity on the serial input ie a cr/lf after the command.
your code might see a RCIDL condition between these chrs and pop into and straight out of sleep
try a small delay before calling sleepmode a 2chr time delay can't hurt here


It often makes a difference adding the NOP right after SLEEP.

which you have already is necessary, the extra two in use may not be adding much value but won't hurt

MOUNTAIN747
- 10th May 2020, 19:11
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



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

richard
- 10th May 2020, 22:36
your code is an uncompilable snippet so its hard to know whats going on


there are issues here


@ MOVF BAUDCON,0 ‘Is RCIDL idel? Set for Idel ‘For testing
@ MOVWF _Avar ‘For testing
Avar=Avar dig 6 ‘For testing

what bank is baudcon in ?
what bank is Avar in ?
from the looks of it Avar must be byte , how can it ever have a Dig 6

whats wrong with one of these ,one of them will produce efficient code i'm sure

if baudcon & 64 then
avar=1
else
avar=0
endif

or

avar=baudcon.6

or

avar=(baudcon&64) >>6

sayzer
- 11th May 2020, 08:40
Here is something from me:

1. Leave the RX pin unconnected for testing. Check the pin state. Does it stay low or high? If it is high and you get int at high already, then it never sleeps.
2. IF all ok, then before sleep instructon, disable GIE and PEIE first. Disable eusart module. Then re-enable it. clear the flags. Then enable GIE, PEIE and lastly usart int bit. Make sure usart flag is cleared, and Usart int bit enabled at the last just before SLEEP command.
3. There should be at least two NOP() immediately after SLEEP.
4. If there are some other ints in your code not shown here, than they may be the cause of wake up. Remember, Most of the ext int sources wake the device up eventhough you do not care for them. Make sure you disable all other ext int sources (if you are using any) before SLEEP.

richard
- 11th May 2020, 08:52
3. There should be at least two NOP() immediately after SLEEP.

not as i read the data sheet




When the SLEEP instruction is being executed, the next
instruction (PC + 1) is prefetched. For the device to
wake-up through an interrupt event, the corresponding
interrupt enable bit must be enabled. Wake-up will
occur regardless of the state of the GIE bit. If the GIE
bit is disabled, the device continues execution at the
instruction after the SLEEP instruction. If the GIE bit is
enabled, the device executes the instruction after the
SLEEP instruction, the device will call the Interrupt Service
Routine. In cases where the execution of the
instruction following SLEEP is not desirable, the user
should have a NOP after the SLEEP instruction.

Ioannis
- 11th May 2020, 10:59
One NOP is enough and should be a good practice to have one in any case. After all a NOP delay is too small to create any short of problem.

Ioannis

sayzer
- 11th May 2020, 16:12
Yes, I checked it again. For some reason I remember to have two NOPs. Sorry for that. Have one or three. It is up to you. :)

Ioannis
- 11th May 2020, 19:11
I rephrase: at least one NOP.

You may have as many as you want of course. Will not argue that. Still, I do not know which case(s) will not need the NOP, so put it there in any case!

Ioannis

MOUNTAIN747
- 12th May 2020, 02:04
Yes, I checked it again. For some reason I remember to have two NOPs. Sorry for that. Have one or three. It is up to you. :)

So I've run all the test Sayzer has suggested. No changes. I then strip code to a couple of lines. I have done this on multipal 1936 and different boards.




Asm
__config _CONFIG1,_FOSC_INTOSC & _CLKOUTEN_OFF & _MCLRE_ON & _BOREN_OFF & _WDTE_OFF & _FCMEN_OFF & _CP_OFF & _CPD_OFF & _IESO_OFF
__config _CONFIG2, _WRT_OFF & _PLLEN_OFF & _STVREN_ON & _BORV_LO & _LVP_OFF
endasm
define OSC 8
OSCCON=%01110000 ;1110=8Mhz
ANSELA=$0
ANSELB=$0
ADCON0=$0
PortA=0
PortB=0
PortC=0
TrisA=%00000001
TrisB=%00001001
TrisC=%00000000
Avar var byte
Bvar var byte
Cvar var byte

SleepMode:
ASM
; BTFSS BAUDCON,RCIDL ;Check for High, no receive in progress
; GOTO $-1 ;return to previous line
; BSF BAUDCON,WUE ;Wake on Rx from Master
; BSF PORTA,1 ;LED

SLEEP
BSF PORTC,1 ;LED
nop
nop
nop .
ENDASM

SLEEP is the first command after which my LED flashes apx. every 2.14seconds.
I then expand the code.


SleepMode:
ASM
; BTFSS BAUDCON,RCIDL ;Check for High, no receive in progress
; GOTO $-1 ;return to previous line

BSF BAUDCON,WUE ;Wake on Rx from Master
BSF PORTA,1 ;LED
SLEEP
BSF PORTC,1 ;LED
nop
nop
nop .
ENDASM
END



I run the code and LED A.1 is on and LED C.1 is blinding every 2.14sec.
I then expand the code.



SleepMode:
ASM
BTFSS BAUDCON,RCIDL ;Check for High, no receive in progress
GOTO $-1 ;return to previous line
BSF BAUDCON,WUE ;Wake on Rx from Master
BSF PORTA,1 ;LED
SLEEP
BSF PORTC,1 ;LED
nop
nop
nop ; Should be in sleep for 10sec.
ENDASM


I run the code and No LED comes on. The program is stuck in the loop BTFSS BAUDCON, RCIDL & GOTO $-1. This is a HARDWARE RESET not caused by any of my code unless something in the configs are at falt. Threre are no interrupts as I have tested all flag bits i can think of. Rx stays LOW. No com is connected to the board. RCIDL should be HIGH but it is not.
CONFIGS !!! Next round of testing.

richard
- 12th May 2020, 05:07
its all the same problem
what bank is baudcon in?
what bank is porta or portc in ?



ASM
BTFSS BAUDCON,RCIDL ;Check for High, no receive in progress
GOTO $-1 ;return to previous line
BSF BAUDCON,WUE ;Wake on Rx from Master
BSF PORTA,1 ;LED
SLEEP
BSF PORTC,1 ;LED
nop
nop
nop ; Should be in sleep for 10sec.
ENDASM

sayzer
- 12th May 2020, 07:57
Your MCLRE is ON.
If you are using power adapter (not battery), make sure you have 100nf cap from MCLRE pin to GND. And I am not even asking about 4K7 - 10K res to vdd; Assuming it is already there.

And, if the osc is giving you issues somehow, then try OSCCON=%01110010.
And check OSC stable bits in OSCSTAT.

richard
- 12th May 2020, 08:27
if you are going to do this sort of thing in asm then you need to understand how banked memory access is
used for this chip. hint [ baudcon is not in access bank ]

Acetronics2
- 12th May 2020, 15:57
I read somewhere in microchip datasheets there might be a @NOP just past the @SLEEP ...

INT1 is the wakeup event.

here it has been working fine for me ... for about 15 years ! ( Lawn tractor computer ... )



Sommeil:

LCDOUT $FE,2, "BYE-BYE "

For I = 8 to 0 Step -1 'Animation arret

LCDOUT $FE,$C0,REP "*"\I," " ' ... 4s
PAUSE 500

NEXT I

PORTB.4 = 0 'Ports LCD à 0
PORTB.5 = 0

PORTC.7 = 0 ' PortC à 0
PORTC.6 = 0
PORTC.5 = 0
PORTC.4 = 0


AlLCD = 1 ' Coupure LCD
AlRef = 0 ' Coupure Vref
ADCON0.0 = 0 ' Désactivation ADC


T3CON.0 = 0 ' arret TMR3
T1CON.0 = 0 ' arret TMR1
T0CON.7 = 0 ' arret TMR0

INTCON.7 = 0 ' Wakeup sans interruptions

INTCON3.0 = 0 ' reset flag INT1
INTCON3.3 = 1 ' validation INT1 pour réveil

Alim = 0 'Coupure alimentation
Signal = 0 'Extinction voyant régime

@ SLEEP
@ Nop ' Redémarrage par mise du contact sans coupure générale
' Arret par décharge capa alim.


INTCON3.3 = 0 'Neutralisation INT1
INTCON3.0 = 0 'Reset Flag INT1
Alim = 1 'Remise alimentation si remise contact rapide.

'************************************************* ****************************
Wakeup: 'Début du Programme - reveil du PIC / Affichage Memoire
'************************************************* ****************************
'
FLAGS = 0 ' Validation Reset LCD

PORTB.4 = 0 'Ports LCD à 0
PORTB.5 = 0

PORTC.7 = 0 ' PortC.4-7 à 0
PORTC.6 = 0
PORTC.5 = 0
PORTC.4 = 0

Reveil = 1
LSelect = 0



Alain

MOUNTAIN747
- 12th May 2020, 17:13
if you are going to do this sort of thing in asm then you need to understand how banked memory access is
used for this chip. hint [ baudcon is not in access bank ]


Thanks guys for all your replies. I really do appreciate the time you've
taken.
So Richard, I should have understood what you were saying the first time. I converted all code to PBP and it looks like RCIDL is set after all. However it didn't change the results.
I then went to battery power, no change. Still a reset every 2.14sec. I also changed several of the configs with no change in results. I may mark this one up as part of the magical mystery tour as I have a work around for the problem. This is one of a couple problems that I could never solve. The other was the inability to make RA.7 a digital I/O. I wonder if my software has some corruption. Yea, when all else fails blame it on the software. Wayne

Ioannis
- 12th May 2020, 18:28
Did you set WDT to OFF?

Ioannis

Ioannis
- 12th May 2020, 20:42
OK, here is the explanation about the NOP:

When the SLEEP instruction is being executed, the next
instruction (PC + 1) is prefetched. For the device to
wake-up through an interrupt event, the corresponding
interrupt enable bit must be set (enabled). Wake-up
occurs regardless of the state of the GIE bit. If the GIE
bit is clear (disabled), the device continues execution at
the instruction after the SLEEP instruction. If the GIE bit
is set (enabled), the device executes the instruction
after the SLEEP instruction, then branches to the interrupt
address (0004h). In cases where the execution of
the instruction following SLEEP is not desirable, the
user should have a NOP after the SLEEP instruction.
The WDT is cleared when the device wakes up from
Sleep, regardless of the source of wake-up.

The key is that before SLEEP the next command is prefetched and might not be what one wants right after a wake, especially after wake from interrupt.

Ioannis

richard
- 12th May 2020, 20:59
a 2 sec reset looks very likely to be wdt



after disabling wdt i would try something like this


SleepMode:
PortA.1=0 ;Indicator LED out on entering SLEEP
ASM
BANKSEL BAUDCON ;bank 3
BTFSS BAUDCON,RCIDL ;Check for High, no receive in progress
GOTO $-1
BSF BAUDCON,WUE ;Wake on Rx from Master
BANKSEL 0 ;bank 0
BSF PORTC,1 ;LED
BCF INTCON ,7
SLEEP
nop
BSF INTCON ,7
ENDASM
PortA.1=1 ;Indicator LED ON at exit SLEEP
return
end

sayzer
- 12th May 2020, 22:09
.....



SLEEP
nop
BSF INTCON ,7




Wayne,
Pay attention to Rihard's code there. The first ting after SLEEP must be NOP.
You did not have NOP as the first thing atfer SLEEP in your code.

and WDT is OFF in config; how can it be an issue?

MOUNTAIN747
- 13th May 2020, 20:02
Success at last, well kind of. New questions are raised as the problem is solved.
Alain's code dimnstrates the purpose of the sleep state, low power, all ports off. This is not required but is good practice.

I followed richards ASM modifications of my poor attempt (years since I wrote ASM. I was trying to brush up)

WDT was always off in Configs so it was never WDT event. Will later read Config addresses to confirm I got what I wanted in memory.

As I enter the ASM code blockk, no LED can be executed after the test for RCIDL and before SLEEP.
Place BSF Portx.x before RCIDL test and SLEEP works.
Place BSF Portx.x after RCIDL test and SLEEP dies not works.
Place BSF Portx.x after BSF BAUDCON, WUE and SLEEP dies not works.
Place BSF Portx.x after BSF INTCON.7 t and SLEEP dies not works.

Before entering the ASM block i can turn on as many LED's as I like and Sleep works as it should.

OK so this is a strange behavure that does not fit any RESET format I can find in the data sheet.

Regarding the data sheet section memtioned by Ioannis.
Wake up will occure regardless of state of GIE bit.
PC SLEEP +1 is prefeched durring SLEEP.

SLEEP with GIE set: NOP may be needed in this case!
Test RCIDL
Set WUE
SLEEP
Wake and exicute next instruction
Call ISR
return to Sleep +2
continue program

SLEEP with GIE clear: no NOP needed but it can't hurt!
Test RCIDL
Set WUE
SLEEP
Wake and exicute next instruction
No ISR called
continue program

In my case I will WAKE on EUSART single byte %00000000. I need the ISR to read RCREG and clear RCIF, then discard Break character. Single NOP will be needed.

So now the adventure of the WAKEUP routine. Thank you for alll your help.
Wayne

Ioannis
- 13th May 2020, 21:50
Glad you did it! Similar cases we faced I guess too.

But that makes me wonder, if we try so hard to solve such things on a PIC, what would happen on a more complex MCU? Would then take years to find what is wrong???

Ioannis

richard
- 14th May 2020, 12:50
As I enter the ASM code blockk, no LED can be executed after the test for RCIDL and before SLEEP.
Place BSF Portx.x before RCIDL test and SLEEP works.
Place BSF Portx.x after RCIDL test and SLEEP dies not works.
Place BSF Portx.x after BSF BAUDCON, WUE and SLEEP dies not works.
Place BSF Portx.x after BSF INTCON.7 t and SLEEP dies not works.

Before entering the ASM block i can turn on as many LED's as I like and Sleep works as it should.

OK so this is a strange behavure that does not fit any RESET format I can find in the data sheet.


you are still not getting it right evidently.

i can do pretty much anything in the asm block before or after sleep, you really should post your code for any meaningful discussion.





#CONFIG
__config _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_OFF & _MCLRE_ON & _CP_OFF & _CPD_OFF & _BOREN_ON & _CLKOUTEN_OFF & _IESO_ON & _FCMEN_ON
__config _CONFIG2, _WRT_OFF & _VCAPEN_OFF & _PLLEN_OFF & _STVREN_ON & _BORV_19 & _LVP_OFF
#ENDCONFIG

include "dt_ints-14.bas"
Include "REENTERPBP.bas"


DEFINE DEBUG_REG PORTB
DEFINE DEBUG_BIT 7
DEFINE DEBUG_BAUD 9600
DEFINE DEBUG_MODE 1

asm
INT_LIST macro
INT_HANDLER RX_INT , getrx, asm ,yes
INT_HANDLER TMR1_INT , _FLASH, PBP,yes
endm
INT_CREATE
ENDASM

index_in VAR BYTE bank0 ' Pointer - next empty location in buffer
index_out VAR BYTE bank0 ' Pointer - location of oldest character in buffer
errflag VAR BYTE bank0 ' Error flag
UartFlag VAR errflag.0
BufferFlag VAR errflag.1
buffer_size CON 16 ' Sets the size of the ring buffer
buffer VAR BYTE[buffer_size] ' Array variable for holding received characters
BufChar VAR BYTE ' Stores the character retrieved from the buffer
Buffrdy VAR BYTE bank0
buff var byte[16]
inx var byte
led var portc.5
led2 var portc.4


RCSTA = $90 ' Enable serial port & continuous receive
SP1BRGL = 51 ;' 9600 Baud @ 8MHz, 0.16%
SP1BRGH = 0 ;
BAUDCON.3 = 1 ' Enable 16 bit baudrate generator


define OSC 8
OSCCON=%01110000 ;8Mhz
ANSELA=$0
ANSELB=$0
ADCON0=$0
PortA=0
PortB=0
PortC=0
TrisA=%00000001
TrisB=%00001001
TrisC=%10001111
Avar var byte
Bvar var byte
Cvar var byte
' rx portc.7
PAUSE 1000
Debug "Start",13 ,13

index_in = 0 ' Initialize ringbuffer variables
index_out = 0
GOSUB error ;CLR AND RESET EUART

T1CON=$31
@ INT_ENABLE RX_INT ; Enable USART RX Interrupts
@ INT_ENABLE TMR1_INT

loopy:
IF errflag Then GOSUB error ' Goto error routine if needed
if Buffrdy then
pie1.4=0
inx=0
while index_in != index_out
GoSub getbuf ' Get a character from buffer
debug bufchar ' Send the character to terminal
buff[inx]= bufchar
inx=inx+1
wend
Buffrdy=0
pie1.4=1
ARRAYREAD buff, 15, loopy,[wait ("sleep")]
gosub SleepMode
endif
GoTo loopy

FLASH:
LED2=!LED2
@ INT_RETURN





SleepMode:
ASM
bcf INTCON ,7
BANKSEL BAUDCON
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
BANKSEL 0
BSF PORTC, 5 ;sleep led on
SLEEP
nop
BCF PORTC, 5 ;sleep led off
bsf INTCON ,7
BANKSEL 0
return
ENDASM



' Get a character from the buffer
getbuf: ' Move the next character in buffer to bufchar
intcon = 0 ' Disable interrupts while reading buffer
index_out = index_out + 1 ' Increment index_out pointer
IF index_out => buffer_size Then index_out = 0 ' Reset pointer if outside buffer
bufchar = buffer[index_out] ' Read buffer location(index_out)
INTCON = %11000000 ' Enable interrupts
Return

' Display an error
error: ' Display error message
INTCON = 0 ' Disable interrupts while in the error routine
IF errflag.1 Then ' Determine the error
debug "over run",13,13 '
Else
debug "rx err",13,13
EndIF
PIR1.4=0
errflag = 0 ' Reset the error flag
RCSTA.4=0 'CREN = 0 Disable continuous receive to clear hardware error
RCSTA.4=1 'CREN = 1 Enable continuous receive
INTCON = %11000000 ' Enable interrupts
RETURN ' repeat




Asm
getrx
; Check for hardware overrun error
banksel RCSTA
btfsc RCSTA,OERR ; Check for usart overrun
goto usart_err ; jump to assembly error routine
; Test for buffer overrun
BANKSEL 0
incf _index_in,W ; Increment index_in to W
subwf _index_out,W ; Subtract indexes to test for buffer overrun
btfsc STATUS,Z ; check for zero (index_in = index_out)
goto buffer_err ; jump to error routine if zero
; Increment the index_in pointer and reset it if it's outside the ring buffer
incf _index_in,F ; Increment index_in to index_in
movf _index_in,W ; Move new index_in to W
sublw _buffer_size-1; Subtract index_in from buffer_size-1
btfss STATUS, C ; If index_in => buffer_size
clrf _index_in ; Clear index_in
; Set FSR with the location of the next empty location in buffer
movlw High _buffer ;Store the High byte of buffer to FSR0H
movwf FSR0H
movlw Low _buffer ; Get the Low byte of buffer[0]
addwf _index_in,W ; Add index_in to point to next empty slot
movwf FSR0L ; Store Low byte of pointer in FSR0
; Read and store the character from the USART
BANKSEL RCREG
movf RCREG,W ; Read the received character
movwf INDF0 ; Put the received character in FSR0 location
BANKSEL 0
SUBLW 13
BTFSC STATUS,Z
BSF _Buffrdy ,0
BTFSC PIR1,TXIF ;ANY MORE ?
goto getrx

finished
BANKSEL 0
INT_RETURN

; Error routines
buffer_err ; Jump here on buffer error
bsf _errflag,1 ; Set the buffer flag
usart_err ; Jump here on USART error
bsf _errflag,0 ; Set the USART flag
BANKSEL RCREG
movf RCREG, W ; Trash the received character
goto finished ; Restore state and return to program
EndAsm

tumbleweed
- 14th May 2020, 17:38
Wake up will occure regardless of state of GIE bit
That part is true. All GIE determines is if you'll wake up and go to the ISR vs just continuing on where you left off.

What wakes you up is the RCIF that occurs when the 00 "break byte" comes in. If RCIE isn't set, then RCIF won't wake you up.

MOUNTAIN747
- 15th May 2020, 23:48
So things now work but I still didn’t understand why some things were acting as they were. As Richard said “You are still not getting it right evidently”. I could finish the project at this point however I was still interested in Configurations which seem to be acting very strange for the Configs I had called for. Richard had used very similar configs to the ones I was using so I started to review the differences. There were no significant differences.

I checked to make sure I had all item in the right Config, 1 or 2. All was fine.
I checked my programmer, melbas Programmer 4.50 list of Config settings and they were different than listed in my program. OOPS! Looking back at the programmer under Options I had checked “Erase before Programming”, Verify after Programming”, and “Update Configurations from file”. So this should take care of everything needed in the Configurations, right?…………WRONG!!!

The second time I looked back at the programmer Options I notice at the bottom of the menu, “More Options”. In most cases this would contain non-essential items that may or may not mater. At the bottom of that menu was “Program” and in that menu the word “Configurations”. Wait a minute; The MAIN menu already set “Update Configurations from File”. Out of curiosity I then checked “Configurations" under the submenus More Options- Program-” and reprogrammed the 1936. To my shock and surprise, all the weird things were gone. LED could be placed inside the ASM block, my PORTA.7 was now a digital I/O. Everything was working correctly. After a couple of weeks of trying to solve bizarre software behavior I find the problem was hardware not software and I would never have gone looking for this if so many of you had not said things like “ not getting it right evidently”. I may have written many programs without being effected by this problem. At this point I can’t be sure that any of my config directive were being programmed into my micros and Configs my have always been defalt. I fell pretty bad that many of you have given of your time. I also have some regret that the programmer menus were written in this manor on some important points. Lesson Learned, don’t take anything for granted! I will however say it was a great exercise in detail study of ASM SLEEP. Thank you again for all your assistance!
Wayne

Ioannis
- 16th May 2020, 11:03
I do not have this programmer, so it would be impossible to guide you there. But since you have the experience, maybe you can drop a line to Charles at Melabs or even register to http://support.melabs.com/forum and report the interface problem there, so it can be fixed.

Glad you nailed it though the really hard way.

Ioannis

richard
- 16th May 2020, 14:11
the most consistent thing i find is that the problem is never what i think it should be

Ioannis
- 16th May 2020, 14:28
Could not agree more Richard!

Ioannis

mpgmike
- 16th May 2020, 15:54
I make it standard practice to list the CONFIGs at the top of my code so it HAS to be programmed, and at the settings of MY choice. For every PIC part your version of PBP is capable of programming, there is an INFO file with all the CONFIG settings, along with the defaults. At the top of the .info file is the defaults, shown in the syntax required for that part. Below that are the options and a brief explanation of what these options affect. Open .info file, copy top default, delete the comment marks (semi-colons), then change as needed.

My INFO files are located at: C:\Program Files (X86)\PBP3_1\DEVICE_REFERENCE.

sayzer
- 16th May 2020, 16:14
the most consistent thing i find is that the problem is never what i think it should be


Then here we go Wayne;

I'm very sure, this never happened to me before
I met you and now I'm sure
This never happened before
Now I see, this is the way it's supposed to be
I met you and now I see
This is the way it should be
This is the way it should be, for programmers
They shouldn't go it alone
It's not so good when your on your own
.....


This Never Happened Before (https://www.youtube.com/watch?v=1GtKOfg-nX4)
Paul McCartney (https://www.youtube.com/watch?v=1GtKOfg-nX4) edited by sayzer

MOUNTAIN747
- 18th May 2020, 20:04
Sayzer, your a good man!!! :)

Ioannis
- 18th May 2020, 21:13
I have the feeling that we maybe much less active members but the quality is high enough!

Ioannis