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.

16f628 and mplab

Status
Not open for further replies.

zaro

New Member
Hi
I am new in pics and MCs, with poor electronics knowledge.
I run my 1st program and...
1) receive the message:
"Register in operand not in bank 0. Ensure that bank bits are correct" at lines: "movwf TRISB, movwf TRISA".what does it mean? something wrong?
2) I used the options: "MPLAB SIM, PICSTART Plus". is it ok?
3) while runing the debuger i notice that the registers change into the expected values, but there is no effect at the output pins. They show steady 5+ volt (of coarse i am runing a blinking led program). Why? Whats wrong?
4) Despite this voltage, there is no current at all. How can?
 
) receive the message:
"Register in operand not in bank 0. Ensure that bank bits are correct" at lines: "movwf TRISB, movwf TRISA".what does it mean? something wrong?

TRISA and TRISB stays in bank1, therefore, to write to TRISA or TRISB, you must access to bank1.


BSF status, rp0 ; bank1
; write to TRISA and TRISB here
;then
BCF status, rp0 ; return to bank0

2) I used the options: "MPLAB SIM, PICSTART Plus". is it ok?

It's oki.

3) while runing the debuger i notice that the registers change into the expected values, but there is no effect at the output pins. They show steady 5+ volt (of coarse i am runing a blinking led program). Why? Whats wrong?

Because you didn't configure the outputs for the pins of ports.

If you only write

MOVLW b'00000000'
MOVWF TRISB ; all portB are outputs

it's not effected.

You have to write

BSF status, rp0
MOVLW b'00000000'
MOVWF TRISB
BCF status, rp0

4) Despite this voltage, there is no current at all. How can?

The output current is 25mA
 
Check section 3.0 MEMORY ORGANIZATION in the Datasheet.
In figure 3-2 show the data memory map of the 16f627-28,
for example TMR0 is in bank0 so you have to tell mplab to switch to bank0, if you want to modify the trisa register you need to switch to bank1.
Personally I always use "BANKSEL" instead to jiggle with the rp bits.
Example
Code:
           BANKSEL   trisa
           movlw     b'00000000'
           movwf     trisa
           BANKSEL   porta
           movlw     .11
           movwf     portb

Expert's say's, go use the rp bit's :!:

STEVE
 
csaba911 said:
Personally I always use "BANKSEL" instead to jiggle with the rp bits

Do note that BANKSEL commands are only possible when writing relocatable code. When writing absolute code it won't work.

zaro said:
1) receive the message:
"Register in operand not in bank 0. Ensure that bank bits are correct" at lines: "movwf TRISB, movwf TRISA".what does it mean? something wrong?
Take a look at the pic's datasheet under the header "data memory organization" (section 3.2). You will see that the data memory or RAM is divided into banks. Files like PORTA and PORTB are in bank0, while files like TRISA and TRISB are in bank1. This means you have to switch to the right bank before you can access a variable. You do this by playing with the bits RP0 and RP1 of the file STATUS like shown in the datasheet.

The message you get 'Register in operand not in bank 0. Ensure that bank bits are correct' is a warning (not an error) from the compiler telling you to make sure you switched to the right bank. You will always get this message, even when your code is correct. You can suppress the message with a line "ERRORLEVEL -302" at the top of your code.

zaro said:
2) I used the options: "MPLAB SIM, PICSTART Plus". is it ok?
MPLAB sim is the built in simulator of MPLAB. It allows you to 'virtually' run your code on your pc to see what happens. Quite handy for timing loops with the stopwatch and testing some math code for example.


zaro said:
3) while runing the debuger i notice that the registers change into the expected values, but there is no effect at the output pins. They show steady 5+ volt (of coarse i am runing a blinking led program). Why? Whats wrong?
need a scematic of how your pic is connected and a listing of your software to help you further.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top