18f452 internal eprom help


Closed Thread
Results 1 to 14 of 14
  1. #1
    TONIGALEA's Avatar
    TONIGALEA Guest

    Question 18f452 internal eprom help

    What is the best way for my to store a table containing 40 (16 bit values) using the DATA command as i only want to store them once at program time.

    i understand the explaination in the manaul for storing 8 bit values as below

    ' Store 10, 20 and 30 starting at location 5
    DATA @5,10,20,30

    But i can't get my head round this bit for 16 bit values
    ' Assign a label to a word at the next location
    dlabel DATA word $1234 ' Stores $34, $12


    assuming i am going to store the following
    Value1=1000 ' at address 0 & 1
    Value 2=2000 'at address 2 & 3
    Value3 =3000 'at address 4 & 5

    How can i do this ?

    Toni

  2. #2


    Did you find this post helpful? Yes | No

    Default

    data @0 232,003,208,007,184,011

    I calculate these as follows:

    1000 dec = 0000 0011 1110 1000 bin

    003 dec = 0000 0011 (byte1)
    232 dec = 1110 1000 (byte0)

    2000 dec = 0000 0111 1101 0000 bin

    007 dec = 0000 0111 bin (byte1)
    208 dec = 1101 0000 bin (byte0)

    3000 dec = 0000 1011 1011 1000 bin

    011 dec = 0000 1011 bin (byte1)
    184 dec = 1011 1000 bin (byte0)

    Hope this helps
    Last edited by CocaColaKid; - 1st June 2004 at 16:08.

  3. #3
    TONIGALEA's Avatar
    TONIGALEA Guest


    Did you find this post helpful? Yes | No

    Thumbs up

    Thank you very much for your reply.
    that was very useful as i just used a spare 24lc128 that i had,
    wrote the 40 word values to it and read it back the contains from addresses in bytes i then used the DATA command.
    This works on a 16f877 but i still can get it to work on a 18f452

    data @0 232,003,208,007,184,011


    Toni

  4. #4


    Did you find this post helpful? Yes | No

    Default

    What version of PBP are you using? Ver 2.42 had problem storing stuff to the eeproom. That has since been corrected in 2.45. I believe it had something to do with not being able to write to either the odd or even eeprom address locations.

  5. #5
    TONIGALEA's Avatar
    TONIGALEA Guest


    Did you find this post helpful? Yes | No

    Default

    I Have pbp 2.45 only just got about 2 weeks ago

  6. #6
    Join Date
    May 2004
    Location
    brighton
    Posts
    149


    Did you find this post helpful? Yes | No

    Thumbs up

    Toni,
    i can comfirm that pbp2.45 does not have that problem
    Although i tested the Read/Write command on a 18f452 and i am using pbp2.45 and it works below is the code i am not quite sure how to do this using the DATA@ command.
    i am presently trying to work out how to do this

    Best Regards
    Isaac




    DEFINE LOADER_USED 1 ' uses a bootloader

    @ __CONFIG _CONFIG1H, _OSCS_OFF_1H & _HS_OSC_1H

    Define OSC 20
    clear

    DEFINE LCD_DREG PORTD ' Use Portd for LCD Data
    DEFINE LCD_DBIT 4 ' Use Upper(4) 4 bits of Port
    ' PORTD-4 thru PORTD-7 connects to
    ' LCD DB4 thru LCD DB-7 respectively
    DEFINE LCD_RSREG PORTE ' PORTE for RegisterSelect (RS) bit
    DEFINE LCD_RSBIT 0 ' PORTE-0 pin for LCD's RS line
    DEFINE LCD_EREG PORTE ' PORTE for Enable (E) bit
    DEFINE LCD_EBIT 1 ' PORTE-1 pin for LCD's E line

    DEFINE LCD_BITS 4 ' Using 4-bit bus
    DEFINE LCD_LINES 2 ' Using 2 line Display
    DEFINE LCD_COMMANDUS 2000 ' Command Delay (uS)
    DEFINE LCD_DATAUS 50 ' Data Delay (uS)

    ' ** Define LCD Control Constants **

    I CON 254 ' Control Byte
    Clr CON 1 ' Clear the display
    Line1 CON 128 ' Point to beginning of line 1
    Line2 CON 192 ' Point to beginning of line 2


    ' Software Defines
    ' ----------------
    ' ** Declare the Variables **
    Temp VAR word ' General Purpose
    Data_Out VAR word ' Data read from the Eeprom
    Data_In VAR word ' Data written to the Eeprom
    address VAR word' Address

    '
    ' Initialise Hardware
    ' -------------------
    ADCON1=7
    TRISA=%00000000
    TRISB=%00000000
    TRISC=%10000000
    TRISD=%00000000


    Pause 1000
    lcdout I,Clr:Pause 30
    lcdout I,Line1," 18F452 TEST "
    lcdout I,Line2+2,"..Power On.. !!"
    Pause 1000 '
    Data_Out=0: Data_In =0: Temp =0

    'WRITE SUB
    '=======
    For address = 0 TO 100 STEP 2 ' Loop 50 times
    Data_In =Temp ' Data_In is data for EPPROM
    WRITE address,Data_In.LowByte
    WRITE (address+1),Data_In.HighByte
    Pause 10 ' Delay 10ms after each write
    Temp =Temp + 1000 ' Add 1000 to the previous value
    Next address



    loop:
    'READ SUB
    '=======
    For address = 0 TO 100 STEP 2 ' Loop 50 times
    lcdout I,Clr:Pause 30
    READ address,Data_Out.LowByte
    READ (address+1),Data_Out.HighByte
    lcdout I,Line1+2," Eprom Values :"
    lcdout I,Line2+2,#address,": ",#Data_Out ' Display Eprom Data

    Pause 1000
    Next address
    GoTo loop

    End

  7. #7
    Join Date
    May 2004
    Location
    brighton
    Posts
    149


    Did you find this post helpful? Yes | No

    Question

    Sorry Toni
    You have got me going now. i have being trying the Data command but it don't work on the 18f452 which is a shame .
    i wonder why someone from Melab hasn't responded to your qury.
    i would like to know myself

    Isaac

  8. #8
    TONIGALEA's Avatar
    TONIGALEA Guest


    Did you find this post helpful? Yes | No

    Red face

    Thanks Isaac for your efforts
    But i am still in the same boat as i started.
    DOES THE NEW PBP SUPPORT THE DATA COMMAND ?

  9. #9
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    If you have V.2.45 then surely it should take you all of two minutes to find out if it works for you... (1) write a simple program using DATA statements, (2) program your preferred chip, (3) read back the contents of EEPROM using your programmer. You don't even have to run your PIC in a circuit.

    According to MeLabs...

    http://www.melabs.com/support/upgrade.htm#pbp

    Previous Release: 2.44...

    Changes PIC18Fxxxx DATA and EEPROM to allow odd locations.

    Melanie

  10. #10


    Did you find this post helpful? Yes | No

    Default

    The DATA command works fine for me. I use it to preload my eeprom addresses at programming time. From then on I use the READ and WRITE commands and everything has worked just fine since I upgraded to 2.45 from 2.42. Try posting the code Toni and maybe there is something that is being over looked.

  11. #11
    TONIGALEA's Avatar
    TONIGALEA Guest


    Did you find this post helpful? Yes | No

    Default

    Hi Mel ,Isaac & CocaColaKid
    Thank you very much for your help i have tried the following code on both the 16f877 and the 18f452 and this does confirm my fears
    PBP DOES NOT SUPPORT the DATA@ command in version 2.45
    the errors are still there or is there something i am missing here?
    Although the link Mel gave below of which i have quoted says that in version 2.44 this was corrected , i can't figure out why this don't work in version 2.45 which is what i have here.
    Could someone please prove me wrong as i don't want to be right on this .

    DEFINE LOADER_USED 1 ' uses a bootloader

    @ __CONFIG _CONFIG1H, _OSCS_OFF_1H & _HS_OSC_1H

    Define OSC 20
    clear

    DEFINE LCD_DREG PORTD ' Use Portd for LCD Data
    DEFINE LCD_DBIT 4 ' Use Upper(4) 4 bits of Port
    ' PORTD-4 thru PORTD-7 connects to
    ' LCD DB4 thru LCD DB-7 respectively
    DEFINE LCD_RSREG PORTE ' PORTE for RegisterSelect (RS) bit
    DEFINE LCD_RSBIT 0 ' PORTE-0 pin for LCD's RS line
    DEFINE LCD_EREG PORTE ' PORTE for Enable (E) bit
    DEFINE LCD_EBIT 1 ' PORTE-1 pin for LCD's E line

    DEFINE LCD_BITS 4 ' Using 4-bit bus
    DEFINE LCD_LINES 2 ' Using 2 line Display
    DEFINE LCD_COMMANDUS 2000 ' Command Delay (uS)
    DEFINE LCD_DATAUS 50 ' Data Delay (uS)

    ' ** Define LCD Control Constants **

    I CON 254 ' Control Byte
    Clr CON 1 ' Clear the display
    Line1 CON 128 ' Point to beginning of line 1
    Line2 CON 192 ' Point to beginning of line 2

    data@0, 0,10,20,30,40,50,60,70,80,90,100
    ' Software Defines
    ' ----------------
    ' ** Declare the Variables **
    Temp VAR byte ' General Purpose
    Data_Out VAR byte' Data read from the Eeprom
    Data_In VAR byte ' Data written to the Eeprom
    address VAR byte' Address


    '
    ' Initialise Hardware
    ' -------------------
    ADCON1=7
    TRISA=%00000000
    TRISB=%00000000
    TRISC=%10000000
    TRISD=%00000000


    Pause 1000
    lcdout I,Clr:Pause 30
    lcdout I,Line1," 18F452 TEST "
    lcdout I,Line2+2,"..Power On.. !!"
    Pause 1000 '


    loop:
    'READ SUB
    '=======
    For address = 0 TO 10 ' Loop 50 times
    lcdout I,Clr:Pause 30
    READ address,Data_Out
    lcdout I,Line1+2," Eprom Values :"
    lcdout I,Line2+2,#address,": ",#Data_Out ' Display Eprom Data

    Pause 1000
    Next address
    GoTo loop

    End

    'With 16F877
    '===========
    ' I get the correct values written to the eeprom and read back as follows
    ' address 0 = 0
    ' address 1 = 10
    ' address 2 = 20
    ' address 3 = 30
    ' address 4 = 40
    ' address 5 = 50
    ' address 6 = 60
    ' address 7 = 70
    ' address 8 = 80
    ' address 9 = 90
    ' address 10 = 100

    'With 18F452
    '===========
    ' I get the values written to the eeprom and read back as follows
    ' address 0 = 0
    ' address 1 = 20
    ' address 2 = 40
    ' address 3 = 60
    ' address 4 = 80
    ' address 5 = 100
    ' address 6 = 0
    ' address 7 = 0
    ' address 8 = 0
    ' address 9 = 0
    ' address 10 = 0

  12. #12
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    Toni,

    as mentioned earlier, I have had the same problem with the 18F series.
    (on the 16F series DATA works just fine)

    I have solved it by updating all my tools to the latest versions.
    see:
    http://www.picbasic.co.uk/forum/show...=&threadid=255

    To me it looks like the results one gets depend on the combination of tools you are using. (MPASM, Programmer-Software, etc.)
    It's not just the version of PBP.

    in PBP 2.44 (or higher) "DATA" is supposed to work but it does not really (at least not on the 18F)

    In the thread mentioned above I have described some kind of "workaround", have you tried this ?



    --------------------------------------------------------------

    There appear to be 10 types of Forum members:
    The ones having that problem
    and the ones not having that problem
    Last edited by NavMicroSystems; - 3rd June 2004 at 23:48.

  13. #13
    TONIGALEA's Avatar
    TONIGALEA Guest


    Did you find this post helpful? Yes | No

    Thumbs down

    Thanks for the work around
    But i still feel its a con by Melab so say that the problem has being fixed when it actually hasn't.
    i specifically upgraded my complier for this partticulat reason

    ITS A SHAME

  14. #14
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    The problem IS fixed... see the new FAQ section for in-depth details.

Similar Threads

  1. 12F683 internal pull up
    By hvacrtech in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 27th July 2008, 02:35
  2. Pic 16 F877 to 18F452...?
    By turkuaz in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 31st October 2007, 15:54
  3. Changing declared variables names on the fly
    By jessey in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 16th December 2006, 06:34
  4. I have a problem with read from internal eprom
    By don_mathew in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 22nd September 2006, 00:48
  5. PIC12F675, accuracy of baud rate with Internal Oscillator
    By Chris Mayhew in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 31st August 2005, 22:41

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