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.

Dumb Question

Status
Not open for further replies.

ormo

New Member
Hi,

I'm very new to PIC programming and this is an incredibly dumb question but I don't seem to be able to get my head around selecting banks.

I am writing for a PIC16F628A and I'm having trouble selecting which bank I am working with. Could someone please tell me the assembly code needed for selecting the different banks? Thanks!
 
You could always use an AVR and not worry about banking =)
 
Hi,

I'm very new to PIC programming and this is an incredibly dumb question but I don't seem to be able to get my head around selecting banks.

I am writing for a PIC16F628A and I'm having trouble selecting which bank I am working with. Could someone please tell me the assembly code needed for selecting the different banks? Thanks!
Hi,
You need to read the datasheet.
 
i need a circiut to work out with pic. but i have totally no idea about it. can anyone help me? is there a standard pic circuit that can suitable for all applications?
 
A simple method I use, when compiling in MPLAB is the built in macro 'banksel'.

For example if you need to select the 'intcon' register, before you do anything use 'banksel intcon'. If you then compile and open the code listing ( *lst file in the same DIR as the assembly) you'll see that MPLAB replcaes this with the two BSF/BCF commands to select the correct bank of the register.

MPLAB has many built in macro's for common 'small' snippets of code, such as:

BC subroutine...

compiles to.

btfsc status,C ; check if carry flag is clear.
goto subroutine ; if carry set, go to subroutine

You don't have to include any files (except the chips inc file) nor change any settings. Its handy when you can't be bothered to check what bank a register is in, or when you just don't want to write a lot of code.

MPASM quick reference guide:
https://www.selectronic.fr/includes_selectronic/pdf/Microchip/ASM-lexique.pdf

pygmali0n: A standard circuit for ALL applications? Aside from adding a power supply, ICSP header and a crystal socket...I don't tihnk anything else will be used for all possible applications. I have made several 'header' boards for this purpose though...so I don't have to breadboard the crystal, or programming header (or reset circuit). Its incredibly basic and only saves a little time, but its something I do for all my micro's...PIC and AVR alike. You just plug in the breadboard, give power to the two power pins and you have I/O's ready to be used.

regards,

Blueteeth
 

Attachments

  • microheaders.jpg
    microheaders.jpg
    92.2 KB · Views: 129
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top