Comments - PIC16 Table Lookups - A Guide - Personal Mechatronics Lab2024-03-29T15:58:40Zhttp://www.pml4all.org/profiles/comment/feed?attachedTo=6212885%3ABlogPost%3A955&xn_auth=noRemember that the last thing…tag:www.pml4all.org,2011-01-28:6212885:Comment:9752011-01-28T14:04:43.000ZJack Sparrowhttp://www.pml4all.org/profile/JackSparrow
<p>Remember that the last thing a table does is retlw the lookup value, meaning you need to call the table lookup routine for it to do what you expect. Hence you'd have to use the macro as follows:</p>
<br></br>
<p><tt>ConvertBcdToAscii:<br></br> call_table TableBcdToAscii<br></br> TableBcdToAscii:<br></br>
dt "0123456789"<br></br>
<br></br>
SomeFunction:<br></br>
...<br></br>
movf some_char, w<br></br>
call ConvertBcdToAscii<br></br>
call LcdWrite<br></br></tt></p>
<br></br>
<p>I suppose the macro would save you typing in the table lookup…</p>
<p>Remember that the last thing a table does is retlw the lookup value, meaning you need to call the table lookup routine for it to do what you expect. Hence you'd have to use the macro as follows:</p>
<br/>
<p><tt>ConvertBcdToAscii:<br/> call_table TableBcdToAscii<br/>
TableBcdToAscii:<br/>
dt "0123456789"<br/>
<br/>
SomeFunction:<br/>
...<br/>
movf some_char, w<br/>
call ConvertBcdToAscii<br/>
call LcdWrite<br/></tt></p>
<br/>
<p>I suppose the macro would save you typing in the table lookup function.</p>
<br/>
<p>I am neither a current AER201 student nor a TA, and my name is not actually Jack Sparrow.</p> Wait. Is your name actually J…tag:www.pml4all.org,2011-01-28:6212885:Comment:9652011-01-28T10:45:08.000ZRitchie Thaihttp://www.pml4all.org/profile/RitchieThai
<p>Wait. Is your name actually Jack Sparrow? I assumed for a while that it was a fake name used by an AER201 student, but your posts seem to indicate the you are a TA. Disney ripped off your name.</p>
<p> </p>
<p>More relevant to the post, this code would be more useful if it were a macro (I haven't tested this):</p>
<p><span style="font-family: courier new,courier;">call_table macro TABLE_BASE<br></br><br></br> movlw HIGH(TABLE_BASE) # Get the top byte of the address of index zero…</span><br></br></p>
<p>Wait. Is your name actually Jack Sparrow? I assumed for a while that it was a fake name used by an AER201 student, but your posts seem to indicate the you are a TA. Disney ripped off your name.</p>
<p> </p>
<p>More relevant to the post, this code would be more useful if it were a macro (I haven't tested this):</p>
<p><span style="font-family: courier new,courier;">call_table macro TABLE_BASE<br/><br/>
movlw HIGH(TABLE_BASE) # Get the top byte of the address of index zero</span><br/><span style="font-family: courier new,courier;">addwf index_hi, w # Add the top byte of the table index</span><br/><span style="font-family: courier new,courier;">movwf PCLATH # Set the top byte of the address</span><br/><span style="font-family: courier new,courier;">movlw TABLE_BASE # Get the bottom byte of the address of index zero</span><br/><span style="font-family: courier new,courier;">addwf index_lo, w # Add the bottom byte of the table index</span><br/><span style="font-family: courier new,courier;">btfsc STATUS, C # If we overflowed, then...</span><br/><span style="font-family: courier new,courier;">incf PCLATH, f # ...increment the top byte of the jump address</span><br/><span style="font-family: courier new,courier;">movwf PCL # Jump to PCLATH:PCL+index</span><span style="font-family: courier new,courier;"><br/></span><span style="font-family: courier new,courier;"> </span></p> Ok awesome. :D woot happy i…tag:www.pml4all.org,2011-01-28:6212885:Comment:9622011-01-28T06:26:09.000ZKeiming Kwonghttp://www.pml4all.org/profile/KeimingKwong
Ok awesome. :D woot happy i chose pic18 now.. less stuff to deal with :P
Ok awesome. :D woot happy i chose pic18 now.. less stuff to deal with :P The same problem is not prese…tag:www.pml4all.org,2011-01-28:6212885:Comment:9612011-01-28T06:24:21.000ZRick Zhanghttp://www.pml4all.org/profile/RickZhang
The same problem is not present for PIC18. Because the programming memory is 16 bits wide, tables can be stored more efficiently. Moreover, PIC18 provides special instructions for reading from and writing to tables. Have a look at the course notes pages 7-65 and 7-66.
The same problem is not present for PIC18. Because the programming memory is 16 bits wide, tables can be stored more efficiently. Moreover, PIC18 provides special instructions for reading from and writing to tables. Have a look at the course notes pages 7-65 and 7-66. Is the same problem present f…tag:www.pml4all.org,2011-01-28:6212885:Comment:9592011-01-28T06:17:27.000ZKeiming Kwonghttp://www.pml4all.org/profile/KeimingKwong
Is the same problem present for pic 18?
Is the same problem present for pic 18? Hear, hear!tag:www.pml4all.org,2011-01-28:6212885:Comment:9572011-01-28T06:10:35.000ZRick Zhanghttp://www.pml4all.org/profile/RickZhang
Hear, hear!
Hear, hear!