What is this

Thread Starter

R!f@@

Joined Apr 2, 2009
9,918
movlw B'00000111'
movwf CMCON ; disable comparator
clrf PORTA
clrf PORTB
movlw B'00001111' ; set PortA directions
tris PORTA
movlw B'00000001' ; set PortB directions
tris PORTB
You see the red high lights.
Why did no tut thought of explain "tris" doing there? :confused:
Does it have to be so complicated?
 

Tahmid

Joined Jul 2, 2008
343
Hi,

The TRIS instruction is an old one, and Microchip discourages programmers from using it. Instead use MOVLW....MOVWF to load the TRIS REGISTERS.
Take a look at these:
http://www.piclist.com/tecHREF/microchip/tris.htm
http://www.electro-tech-online.com/micro-controllers/27582-what-mean-tris-porta.html This should help clear things

Quoted from the 2nd link:
On older versions of the PIC architecture there was a specific instruction that loaded the the TRIS register. On the newer versions you use a move instruction just like every other file register. If you read the datasheets really carefully they discourage the use of the dedicated instruction in favor of the more generic move instruction
Hope this helps.
Tahmid.
 

t06afre

Joined May 11, 2009
5,934
This instruction was used in older PICs. As I have understood this instruction or type of coding is outdated and should not be used as a recommendation from Microchip.
use this instructions
Rich (BB code):
movlw B'00001111' 
movwf TRISA ; set PortA directions
 

Thread Starter

R!f@@

Joined Apr 2, 2009
9,918
One more problem.
What is stack overflow at address blah blah blah
and why does we need the tables at certain location of the file.
I'm having trouble compiling if I put tables at different places.
which means the file should be in a proper order.
I haven't seen any one explaining how the order should be say for example.
When and where the defines should be?
after what should the tables come?
where should the messages be located in the case of a LCD display messages?

I think I know where the ISR should be located, It should come after ORG 0x04 and should end with a RTFEI. What will happen if I place that somewhere else.

Why does the Main program routine does not always appear after the interrupt service vector in some files that I have seen.

I like to know how to create a .inc file, since I have seen ASM's with a lot of
#include display.inc
#include mind_confusing.inc
#include headache.inc.

the best part is I donno where these files are and why if I copy paste the context in an .inc file to an ASM, it won't compile unless it is located in a certain place.

And even if I can compile I get stack overflow at location 0X00%$#

It would be helpful if anyone can point out these one by one.
 

t06afre

Joined May 11, 2009
5,934
If we simplify somewhat a interrupt can be compered to a call to address 0x4. So then a interrupt occur the CPU will automatically call address 0x4 and execute code from that point. If you do dot enable interrupt you can have code from 0x000. else you have to do something like this
Rich (BB code):
org 0x0
goto main
org 0x4
;put your ISR here
 
org main
;put your main code here
[\code]
 

Thread Starter

R!f@@

Joined Apr 2, 2009
9,918
patronizing, ionizing may be, what ever you call it, I find it funny. :D
!!GRIN!!! of course I know goto and call, I have been using 'em.

My turn to get back at you.
Please read my post line by line :p.
 

t06afre

Joined May 11, 2009
5,934
The Microchip application note AN556 discuss the use of tables. Also you get stack overflow then you do to many consecutive call instructions/interrupts without issuing a RETURN/RETFIE command. The stack can only hold a certain amount of return addresses. The number will vary from different microchip MCUs
 
Last edited:
Top