Continue to Site

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.

  • 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.

Indirectly accessing the access bank (18F)

Status
Not open for further replies.

pittuck

New Member
Hi need some ASM help

Ok i am just working on some code [and i realise the W and other registers have not been saved yet, do that later, perhaps after i get some breaky, anyhow.

Code:
isr

    ; Handle Interupts
    BTFSC PIR1, RCIF            ; If RCIF Set GOTO Debug
    GOTO Debug
    GOTO Int_Exit
    
    Debug
        
        CALL Getc               ; Get The Command
        MOVWF debug_command
        
        MOVLW 0x7A
        CALL Putc               ; Send We are here
        
        if debug_command == 0x01   ; Its a debug command
            CALL Getc           ; Get The Data
            MOVWF debug_data
            
            ***
            CALL Putc
        endif
        
    GOTO Int_Exit

Int_Exit

RETFIE

Basically i send a command over RS232, wait for a reply, then send another byte, in this case a memory address which points to a location in the access bank. what i want to do is put the value of the data at the address stored in debug_data to W so it can be sent back to the PC.

Any ideas? I think there was something in elektor a few months ago, i will search my room for it now, but neone have any ideas?
 
Ok, elektor had the answer ;) here is the code for the ISR now, just to show how its done.

Code:
isr

    MOVWF W_TEMP                ; W_TEMP is in virtual bank
    MOVFF STATUS, STATUS_TEMP   ; STATUS_TEMP located anywhere
    MOVFF BSR, BSR_TEMP         ; BSR located anywhere

    ; Handle Interupts
    BTFSC PIR1, RCIF            ; If RCIF Set GOTO Debug
    GOTO Debug
    GOTO Int_Exit
    
    Debug
        
        CALL Getc               ; Get The Command
        MOVWF debug_command
        
        MOVLW 0x7A
        CALL Putc               ; Send We are here
        
                                ; Its a debug command
        if debug_command == 0x01
            CALL Getc           ; Get The Data
            MOVWF debug_data
            
            if debug_data <= 0x7F
                MOVLF FSR0H, 0x00
            else
                MOVLF FSR0H, 0x0F
            endif
            
            MOVF debug_data, FSR0L
            MOFF INDF0, W
            CALL Putc
        endif
        
    GOTO Int_Exit

    Int_Exit

    MOVFF BSR_TEMP, BSR         ; Restore BSR
    MOVF W_TEMP, W              ; Restore WREG
    MOVFF STATUS_TEMP,STATUS    ; Restore STATUS

RETFIE

Erm, well there is a 12 bit address for all of the RAM, the lower 128 are the lower access register, and the upper 128bytes are the upper access register (and are also the SFR). (giving a nice 128bytes of RAM, access to all SFR's and no bank switching needed, unless u use the other banks of course...)

Anyhow, the lower 8 bits of the 12 bit address goto FSR0L and the upper 4 goto the FSR0H, then u can read / write to the register INDF0.

lol, easy really.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top