What is this

Discussion in 'Programmer's Corner' started by R!f@@, Mar 1, 2010.

  1. R!f@@

    Thread Starter AAC Fanatic!

    Apr 2, 2009
    8,754
    760
    [​IMG][​IMG]
    You see the red high lights.
    Why did no tut thought of explain "tris" doing there? :confused:
    Does it have to be so complicated?
     
  2. Tahmid

    Active Member

    Jul 2, 2008
    344
    25
    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:
    Hope this helps.
    Tahmid.
     
    R!f@@ likes this.
  3. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    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
    Code ( (Unknown Language)):
    1.  
    2. movlw B'00001111'
    3. movwf TRISA ; set PortA directions
    4.  
     
    R!f@@ likes this.
  4. R!f@@

    Thread Starter AAC Fanatic!

    Apr 2, 2009
    8,754
    760
    Now that's more like it.
     
  5. R!f@@

    Thread Starter AAC Fanatic!

    Apr 2, 2009
    8,754
    760
    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.
     
  6. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    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
    Code ( (Unknown Language)):
    1.  
    2. org 0x0
    3. goto main
    4. org 0x4
    5. ;put your ISR here
    6.  
    7. org main
    8. ;put your main code here
    9. [\code]
     
  7. R!f@@

    Thread Starter AAC Fanatic!

    Apr 2, 2009
    8,754
    760
    My dear friend, that's a partial answer, to be exact you are confusing me more
     
  8. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    This is not meant to be patronizing. But you do know the difference by the goto and call instruction?
     
  9. R!f@@

    Thread Starter AAC Fanatic!

    Apr 2, 2009
    8,754
    760
    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.
     
  10. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    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: Mar 2, 2010
Loading...