Hello.
I am writting a program where at the beggining i declare which variables are used in the program using
Code:
cblock h'20'
timer0
timer1
NumL
huns
tens
ones
BIN
endc
When i run the simulator i can see that these registers are messed up as variables are declared elsewhere in the GPRs. They are declared at 0A0h instead of 020h.
any help?
the pic i am using is 16f873
Thank you
Hello.
I am writting a program where at the beggining i declare which variables are used in the program using
Code:
cblock h'20'
timer0
timer1
NumL
huns
tens
ones
BIN
endc
When i run the simulator i can see that these registers are messed up as variables are declared elsewhere in the GPRs. They are declared at 0A0h instead of 020h.
any help?
the pic i am using is 16f873
Thank you
Your program seems lacking a lot of parts it needs, it gives 104 errors when I try to assemble it!
The problems are probably in the missing parts at the beginning, for a start you don't even specify your processor?. Also, why not use the include files provided, rather than write your own definitions, have a look at my tutorials for examples of how to layout PIC source code.
If this is your first program, I would suggest you start off simpler, jumping straight into interrupts and analogue converters is making life far more complicated for you. I would suggest starting off simply and working up, again my tutorials may be helpful.
hello and thank you for your reply.
I think you got me wrong. I know a thing or two for microcontrollers about interrupts and a/d. Yes you are right that my program is not complete. It isnt. i just started it and i came up with this problem. When i compile it i get no errors at all. The program is working fine on the simulator with only problem the GPR's as i explained you before.
That must be something i don't know about GPRs. If i write:
The resulting binary code for MOVWF 0x20 is indeed 0x0A0. You can see it in table 13-2 of the PIC16F87X datasheet.
Remember that for direct addressing, only seven bits are used and therefore 128 locations on a given memory bank are directly addressable at a given time.
Right, thanks to motion I now see what you are doing, you're looking at the machine code produced by the assembler!. This seems rather a strange thing to be doing? - fair enough, I did it, many years ago - but I was writing a PIC disassembler!.
All the PIC instructions are listed in their data sheets, it's hard to miss, it's a complete listing of all 35 instructions.
They are also listed in Appendix B.1 of the MPASM help file, which is installed along with MPLAB - which is usually easier to find than the datasheet.
maybe thereis a misunderstanding or something i do not know. The problem at the begginig was:
The timer0 variable EVEN IF it is declared to be at 0x20 address, WHEN i run the simulator i can see that it is saved at 0xA0 address.**broken link removed**
I dont know if the rest of my comments are relevant. Thank you for answering me. The actual problem is shown in the picture
Address 0x20 and 0xA0 are on the same position, but in a diffirent bank
0x20 is bank 0 and
0xA0 is bank 1...
If you save something to your timer0 variable at address 0x20, but it is address 0xA0 that changes then this means you are in the wrong bank (bank1 - while you should be in bank0)
hmm
thnx EXO.
i though i had already did that and was not working. Seems i was wrong. I tried it again now and it works!!!
Thank you very much for your time and replies, and sorry causing too much trouble for things i should already know by now....
thanx