• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Memory Restricted In Watch Window

Inquisitive

Super Moderator
Thread starter #1
I need some assistance getting this solved.

I'm still learning to crawl in PIC microcontrollers. Working with a PIC 16F628A

Code:
;=============================================================================
;    Bin4B.asm                    3-4-18
;=============================================================================
;    Slow output binary count is stopped, started
;    and reset with push buttons. This version uses a
;    subroutine for the delay...
;    Processor:    PIC 16F628A
;    Hardware:    BIN Demo System
;    Clock:      
;    Inputs:        Push Buttons RA0, RA1 (active low)
;    Outputs:    RB0 - RB7 LEDs (active high)
;
;    WDTimer:    Disabled
;    PUTimer:    Enabled
;    Interrupts:    Disabled
;    Code Protect:    Disabled      
;=============================================================================
;              16F628A
;         ____ ____
;    RA2-| 1 U 18 |-RA1
;    RA3-| 2   17 |-RA0
;    RA4-| 3   16 |-OSC1/RA7
;    MCLR-| 4   15 |-OSC2/RA6
;    VSS-| 5   14 |-VDD
;    RB0-| 6   13 |-RB7
;    RB1-| 7   12 |-RB6
;    RB2-| 8   11 |-RB5
;    RB3-| 9   10 |-RB4
;         ----------
;  
    list    p=16f628a
    include    <p16f628A.inc>
    radix    hex
    __CONFIG   _CP_OFF & _WDT_ON & _PWRTE_ON & _XT_OSC
;
;...... Register Label Equates ...............................................
;
porta    EQU    05        ; Port A Data Register
portb    EQU    06        ; Port B Data Register
timer    EQU    0C        ; Spare register for delay
; Input Bit Label Equates ....................................................
;inres    EQU    0        ; 'Reset' input button = RA0
;inrun    Equ    1        ; 'Run' input button = RA1
;
    cblock    0x20      
    inres            ; 'Reset' input button = RA0
    inrun            ; 'Run' input button = RA1
    endc
    movlw    .0
    movwf    inres
    movlw    .1
    movwf    inrun
;
;*****************************************************************************
; Initialise Port B (Port A defaults to inputs) ..............................
;
    MOVLW    b'00000000'    ; Port B Data Direction Code
    TRIS    portb        ; Load the DDR code into F86
    GOTO    reset
;
; 'delay' subroutine .........................................................
;
delay    MOVWF    timer        ; Copy W to timer register
down    DECFSZ    timer        ; Decrement timer register
    GOTO    down        ; and repeat until zero
    RETURN            ; Jump back to main program
;
; Start main loop ............................................................
;
reset    CLRF    portb        ; Clear Port B Data
;
start    BTFSS    porta,inres    ; Test RA0 input button
    GOTO    reset        ; and reset Port B if pressed
    BTFSC    porta,inrun    ; Test RA1 input button
    GOTO    start        ; and run count if pressed
;
    INCF    portb        ; Increment count at Port B
    MOVLW    0FF        ; Delay count literal
    CALL    delay        ; Jump to subroutine 'delay'
;
    GOTO    start        ; Repeat main loop always
    END            ; Terminate source code
The issue is these restricted memory errors in the watch windows. How do I solve this?

RestrictedMemeoryError.PNG


Using MPLAB IDE 8.92 with MPLAB SIM

Why can I not watch RA0 and RB0 ? Suggestions anyone.
 

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
#2
The watch window is for registers The three symbols you have used have no address signed to them
All you have is PORTA = address 5 and the binary view.. You can't put bit values in...

RB2 = 0x0C ... Obviously wrong.. never use the watch... I just use the SFR viewer..
 

Pommie

Well-Known Member
Most Helpful Member
#3
RA0 is bit zero of port A, so you are looking at address zero which is INDF which is a restricted area.

Mike.
 

Inquisitive

Super Moderator
Thread starter #4
I just cannot get this program to work. It produces no error messages on compile. But logically it does not produce the correct result.

Bin4Schematic.PNG
 
#5
You need to watch out for things like .... "INCF portb" .... without specifying the file register it defaults to the W register ...

INCF portb, F ... is probably what you want, but again there still could be an issue. Sometimes you can't write directly to a port like that.

instead try something like...

INCF tempVariable,F
MOVF tempVaraible,W
MOVWF portb
 

Inquisitive

Super Moderator
Thread starter #7
No, not forgotten. That is a sample straight out of a textbook. Hence I do not have enough background information yet to solve the issue and the plea for mentoring. I searched for errata on the publishers website and came up empty.

CMCON has not even been mentioned in the textbook as of yet.
 

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
#8
No, not forgotten. That is a sample straight out of a textbook. Hence I do not have enough background information yet to solve the issue and the plea for mentoring. I searched for errata on the publishers website and came up empty.

CMCON has not even been mentioned in the textbook as of yet.
Well.. If you want to use RA0 and RA1 as digital inputs you'll have to turn it off..
 

Nigel Goodwin

Super Moderator
Most Helpful Member
#9
No, not forgotten. That is a sample straight out of a textbook. Hence I do not have enough background information yet to solve the issue and the plea for mentoring. I searched for errata on the publishers website and came up empty.

CMCON has not even been mentioned in the textbook as of yet.
Is your book specific to the 16F628? (highly unlikely), CMCON is pretty well specific to that device and MUST be turned OFF to use the port as normal.

If you check my tutorials (which use the 628) you'll see all programmes do exactly that - http://winpicprog.co.uk/pic_tutorial1.htm
 

Inquisitive

Super Moderator
Thread starter #10
Heard the 16F628A was identical to the 16F84A. The tutorial is based on a 16F84A and I was converting it to 628A. I have stacks of books based on the 16F84A and never had the time to get to them. Shame to throw them out.

Thanks for your insight.
 

Inquisitive

Super Moderator
Thread starter #11
I see now I should have offered more information
 

Latest threads

EE World Online Articles

Loading

 
Top