PA3040
Advanced Member level 3
Attachments
Last edited:
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Hi, Switch to the required bank first and then write the instruction.
sys_init clrf PORTC
banksel TRISC
clrf TRISC
banksel PORTC
return
Hi,
Seems that you are initializing the micro. Please see the start up value of the status register when microcontroller boots up. If i not forgetting the default bank select is bank zero. When you clear the port and then select the tris register the bank switches and then after it switches back to bank 0. In short MPLAB is not showing wrong data. Assembler translates from this file to hex file. How could it be wrong? Hope you understood that! Enjoy
#include <p16f877a.inc>
LIST p=16f877a
__config 3f39
org 0x00
Start goto main
main call sys_init
sys_init clrf PORTC
banksel TRISC
clrf TRISC
banksel PORTC
return
end
Hi, I clearly understood your question in first few posts. You can understand it like this. Say you have two memories of some 'X' bytes. You want to write data to Memory 1, You select its CS pin and write data to lets say 0x20 location. Now if you want to write data to memory 2 you deselect memory 1 (switches bank) and write to 0x20 location again of memory 2. Now say that 0x20 location name is portc in memory 1, what should be the name of memory 2 of same location? it shold be portc there rather than trisc. Means to say that MPLAB assembler selects memory/bank correctly and write data accordingly. The names do not matter here only the address location and bank matters. Hope it is clear now. Chill
MPASM 5.36 ROTATE_OFF.ASM 4-16-2013 16:13:08 PAGE 1
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00001
00002 #include <p16f877a.inc>
00001 LIST
00002 ; P16F877A.INC Standard Header File, Version 1.00 Microchip Technology, Inc.
00400 LIST
Warning[205]: Found directive in column 1. (LIST)
00003 LIST p=16f877a
Warning[205]: Found directive in column 1. (__config)
2007 3F39 00004 __config 3f39
0000 00005 org 0x00
0000 2801 00006 Start goto main
0001 2002 00007 main call sys_init
00008
00009
00010
00011
0002 0187 00012 sys_init clrf [COLOR="#FF0000"]PORTC[/COLOR]
0003 1683 1303 00013 banksel TRISC
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
0005 0187 00014 clrf [COLOR="#FF0000"]TRISC[/COLOR]
0006 1283 1303 00015 banksel PORTC
0008 0008 00016 return
Warning[205]: Found directive in column 1. (end)
00017 end
MPASM 5.36 ROTATE_OFF.ASM 4-16-2013 16:13:08 PAGE 2
Hi,
Think it must be a problem with version 8.53 as your code shows correctly in v8.90 ( though beware there is mention on Microchips Programmer forum about a bug that affects some 16F chips and suggests you reload v8.8)
Edit
Opps - was looking at the Disassembly listing, not the Program Memory listing, it does still show the PORTC when its actually TRISC - clearly it must be a short coming of that listing in that it does not interpret the register with the bank selected when you View it, though clearly it does correctly run the code.
Have just added ARESL in bank 1 but again the program listing shows ADRESH .
Banksel PORTC
clrf TRISC