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.

18F Bank Switching RE: SFR

Status
Not open for further replies.

pittuck

New Member
Ok, my code:

Code:
; Mouse Rover MK1
; For uni interviews
; 
; Spec:
;
; Ultra Sonic SRF04
; Sharp IR Sensors x2
; Motor Control
; Wireless
; Motor Odomentry

; By MARTYN PITTUCK, Started 07 Nov 04 @ 9:30PM

; Start off by stating the processor and including the directives
    Processor 18F452
    include "P18F452.INC"

; Start of CUSTOM directives
    prog_status     Equ     0x00
; End of CUSTOM directives

; Bootloader start, same as interupt vector...
    Org 0x0000
    GOTO Main 

    Org 0x0008
    GOTO int_server ; Goto the interupt server routine, need a interupt escape...
                    ; Can escape if setup bit is not enabled

; START OF SETUP
setup

; Clear PORTA
    BANKSEL PORTA ; Bank 1
    MOVLW b'00000000' ; All Outputs low
    MOVWF PORTA ; Clear PORTA, All Outputs Low. Bank Previously set

; Configure Analog on PORTA
    BANKSEL ADCON1
    MOVLW 0x07
    MOVWF ADCON1

; Set TRISA
    MOVLW b'00000000' ; All Outputs
    MOVWF TRISA ; Move W to TRISA

; Set TRISB
    MOVLW b'00000100' ; RB2[RX] is input
    MOVWF TRISB ; Move W to TRISB

; Set PORTB
    MOVLW b'00000000' ; All Outputs low
    MOVWF PORTB ; Move W to PORTB

; For now we will use RB3 - but later all LED's will run off i2c bus...
    BSF PORTB, 0x04 ; Turn Status LED On (Everything OK)

RETURN
; END OF SETUP ROUTINE

Main


RETURN

int_server


RETFIE

END

Ok so this is very early code for a 18F452

Do i need to use the BANKSEL or any other type of Access Bank?

i.e

Code:
; Configure Analog on PORTA
    BANKSEL ADCON1
    MOVLW 0x07
    MOVWF ADCON1

would be:

Code:
; Configure Analog on PORTA
    MOVLW 0x07
    MOVWF ADCON1

Or

Code:
; Configure Analog on PORTA
    MOVLW 0x07
    MOVWF ADCON1, 0

Where the access bank is stated.

My guess is the former as in the .inc file for MPASM:

Code:
ADCON1          EQU  H'0FC1'

0xoFC1 is in the SFR 'Bank' so it could be a direct addressing

Many thanks,

Martyn
 
yeah - i would do some testing but i not got a 18F set up ATM!

Making a Palm APP which has all the 18F ASM commands in it ATM, i keep losing my printout of them...
 
you dont need to adress the access bank, the address in the include file is the entire address hence the length. If you are lazy and dont need all the banks you can just keep everything in one bank, set the bank bits and you never have to worry about changing banks...
 
ok, but the Access bank does not have a number right? Its a mix of the first half of bank 1 and the last half of the SFR bank.

So how would i address it?

Lol,

Its early ATM, i will read datasheets this evening when i get back from college.

Thanks,

- Martyn
 
The MPLAB assembler MPASM is smart enough to determine whether an operand is in the access bank or not. Therefore it is not required to explicitly assign a value to the A bit in the operand.

You can verify this by looking at the binary code produced in the output listing file. They are identical.

Code:
6EC1   MOVWF ADCON1

and

Code:
6EC1   MOVWF ADCON1,0
 
Well at the moment its pretty dull, base + mounted motors (from swallow.co.uk with encoders)

But i got my palm app finished :D

Here is a pre-release version.
 

Attachments

  • pic18is.gif
    pic18is.gif
    1.6 KB · Views: 677
Ah its just a program that has all the ASM cmd's and a brief description. Later i might add example code for each one.

See this screeni ;) [there is a typo or 2, will fix that later
 

Attachments

  • p18is.gif
    p18is.gif
    1.8 KB · Views: 662
only the motors

**broken link removed**

Not the best pic in the world, my real camera was ooa. But is shows the size of it. Eventually it will be a micromouse, but i want to work on the drive system first.
 
pittuck said:
only the motors

**broken link removed**

Not the best pic in the world, my real camera was ooa. But is shows the size of it. Eventually it will be a micromouse, but i want to work on the drive system first.
looks cool...
 
Status
Not open for further replies.

Latest threads

Back
Top