more than 8 bit for tables in flash (16F87x)


Closed Thread
Results 1 to 14 of 14
  1. #1
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289

    Default more than 8 bit for tables in flash (16F87x)

    Is there any way to store more than 8 bit (f.e. 10) in a 14-Bit-Word inside the flashmemory for tables ?

    All MPASM-directives only allow 8 Bit.
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Question Some explanation please ...

    Hi, Wumpus

    as we are in the PbP forum ... you could have a closer look to lookup2 and lookdown2 statements that deal with 16bits values ...
    a look to WRITECODE or READCODE could be valuable too ...

    That reminds me an old post from MEL about that subject ..." Playing with ... as a playground "
    that one also : http://www.pbpgroup.com/modules/wfse...p?articleid=10

    for MPASM exclusive use, two times the RETLW xx method seem to be unavoidable ... as W register is "only" 8 bits ...

    Alain
    Last edited by Acetronics2; - 16th May 2006 at 16:03.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by BigWumpus
    All MPASM-directives only allow 8 Bit.
    maybe I am mistaken, but I thought the MPASM DATA directive gave you full access to store 14 bit numbers in code space ... see DATA in MPASM help topics

    Paul Borgmeier
    Salt Lake City, Utah
    USA

  4. #4
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Unhappy

    READCODE ist used... it can read 14-Bit-Code into Word-Variables !
    (Writecode too!)

    But, you can't put 14-Bit-parameters in the flash.

    With the 18F... it will work (DW 1234h)

    I think somebody was pretty in love with the RETW-statement (or how else it is written).
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Like Ace said, LOOKUP2 will do the job, but it's a bit code heavy.

    This is a variant of the Strings idea that allows Very Large 14-bit WORD sized tables in code space.
    Code:
    Address   VAR  WORD
    DataWord  VAR  WORD
    Offset    VAR  WORD
    
    '-----------------------------------------------------------------------------
    ASM
    GetAddress macro Label, Wout       ; Returns the Address of a Label as a Word
        CHK?RP Wout
        movlw low Label
        movwf Wout
        movlw High Label
        movwf Wout + 1
        endm
    ENDASM
    
    '-----[The DATA table]--------------------------------------------------------
    ASM
    DataTable
        DW  1234h, 2178h
    endasm
    
    '-----[Retrieve from DATA table]----------------------------------------------
    Offset = 1
    @  GetAddress   DataTable, _Address
    Address = Address + Offset
    ReadCODE  Address, DataWord
    
    LCDOUT  $FE, 1, HEX4 DataWord
    DT

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Or, if you only have One table to deal with, you could do it this way...
    Code:
    DataWord  VAR  WORD
    Offset    VAR  WORD
    DataTable CON  EXT
    
    '-----[The DATA table]--------------------------------------------------------
    ASM
    DataTable
        DW  1234h, 2178h
    endasm
    
    '-----[Retrieve from DATA table]----------------------------------------------
    Offset = 1
    ReadCODE  (DataTable + Offset), DataWord
    
    LCDOUT  $FE, 1, HEX4 DataWord
    <br>
    DT

  7. #7
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Default

    Hi Darrel,

    Uuuuhhh......

    DW is not working for PIC16F.... it places a WORD packed in 2 BYTEs with a RETLW added.

    READCODE cannot adress the table direct, you have to use the macro, i guess. (but I will see what this CON EXT will be...)

    LOOKDOWN2 is ... I don't use it. My routine looks like this:
    ;================================================= =========================
    NTC2Temp:
    @ SetI2CText _Tab_NTC
    I=0 ;Anfangstemperatur der Tabelle
    Gosub ReadWord ;Anfangsspannungswert ADC
    While DummyW ;solange die Tabelle noch nicht durch ist
    Dummy2W=DummyW:Gosub ReadWord
    For J=1 to 5
    If ADC_NTC<Dummy2W Then ;wenn Temperatur noch nicht gefunden
    Dummy2W=Dummy2W-(Dummy2W-DummyW)/(6-J):I=I+1
    Endif
    Next J
    Wend
    Dummy=I:Return

    ;================================================= =========================
    ;Umrechnung NTC
    ;gemessener ADC-Wert auf Temperatur
    Tab_NTC:
    @ DW 879,852,821,786,747,704 ;0-25°C
    @ DW 659,612,564,516,468,419 ;30-55°C
    @ DW 375,338,303,270,239,211 ;60-85°C
    @ DW 187,166,147,130,116,103 ;90-115°C
    @ DW 92,82,73,65,58,52,47 ;120-150°C
    @ DW 0

    ;================================================= =========================

    the datapoints (every 5 degrees) must be interpolated, so LOOKDOWN2 is not realy good to me.
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

  8. #8
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by BigWumpus
    DW is not working for PIC16F.... it places a WORD packed in 2 BYTEs with a RETLW added
    I think you've got it backwards.
    This is DW data compiled for a 16F877. It places each 14-bit word value in successive program word locations, which can then be read with READCODE.
    Code:
    0286                  00490 DataTable
    0286   1234 2178 0001 00491     DW  1234h, 2178h, 0001h, 0781H
           0781
    This is the same data used in a LOOKUP2 statement.
    Code:
                          00516         LU2RET?C        01234h
    0301   3434               M         retlw   low (01234h)
    0302   3412               M         retlw   high (01234h)
    0303   3400               M         retlw   0
                          00517         LU2RET?C        02178h
    0304   3478               M         retlw   low (02178h)
    0305   3421               M         retlw   high (02178h)
    0306   3400               M         retlw   0
                          00518         LU2RET?C        001h
    0307   3401               M         retlw   low (001h)
    0308   3400               M         retlw   high (001h)
    0309   3400               M         retlw   0
                          00519         LU2RET?C        00781h
    030A   3481               M         retlw   low (00781h)
    030B   3407               M         retlw   high (00781h)
    030C   3400               M         retlw   0
    It's the LOOKUP2 that puts the retlw's in there.

    As for the examples above. I have run the code. It works.

    You didn't include the ReadWord subroutine with your code so I can't tell how yours is tryng to read the NTC table.
    <br>
    DT

  9. #9
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor
    I think you've got it backwards.
    This is DW data compiled for a 16F877. It places each 14-bit word value in successive program word locations, which can then be read with READCODE.
    Code:
    0286                  00490 DataTable
    0286   1234 2178 0001 00491     DW  1234h, 2178h, 0001h, 0781H
           0781
    F***

    I use MP, not MPASM - Argh.

    MP compiles DW like this:

    Code:
      4860					; D:\BFC\BFC200~1.BAS      	01508	    @ DW 942,915,884,848,808
      4861					
      4862						ASM?
      4863	1282- 34AE 3403 3493 3403	 DW 942,915,884,848,808
    	1286- 3474 3403 3450 3403
    	128A- 3428 3403
      4864					
      4865						ENDASM?
    OK, I had to use MPASM !
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

  10. #10
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Interesting... I didn't know it did that.

    Yet another reason to Not use PM. &nbsp;

    DT

    I guess I better update the <a href="http://www.picbasic.co.uk/forum/showthread.php?t=3891">EXT</a> thread to read MPASM only for the lookup Table. Thanks.

  11. #11
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Default

    OK,

    I switched to MPASM. Just look inside the Include-files of the MPASM to figure out the __config-command,
    comment it out in the Include-files of the PBP .... ;-(

    Then it works!

    I got 14-Bit-values in the flash ! This seems to be a weak part of MP ! ;-(

    I preffered to use MP, because the errors are located inside the code....
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

  12. #12
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    That's an interesting finding dudes! As Darrel's said, yet another reason to not use PM!

    MPASM allow too much interesting feature that PM doesn't. Also, as a major reason of using it, it works with ALL PIC. But it also assume than the person back of the keyboard use/understand and want to use those feature. As assembler seems to be a common fear here... i doubt many will change their mind and use MPASM only for the reasons we stated.

    Anyways, thanks BigWumpus and Darrel.

    Oh Darrel, you finnally got me with the INCLUDE file. In conjuction with MESSG (for kinda help file) they're really usefull. Apologies!
    Last edited by mister_e; - 17th May 2006 at 15:11.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  13. #13
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hi Steve, that's Great!

    I guess I can check off your name in my list of people to convert to Include files.

    Let's see... 2 down, and 2,435 to go. Now we're cooking.

    DT

  14. #14
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    LMAO! Well at least, there's some progress
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. How do I use 10 bit A/D on 8 bit Pic? 12F675
    By polymer52 in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 1st April 2020, 20:10
  2. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 07:55
  3. How to receive stream of bytes using PIC USART
    By unifoxz in forum mel PIC BASIC Pro
    Replies: 34
    Last Post: - 20th June 2009, 10:38
  4. PICBasic newbie problem
    By ELCouz in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 12th February 2008, 00:55
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts