I have a problem with read from internal eprom


Closed Thread
Results 1 to 9 of 9
  1. #1
    don_mathew's Avatar
    don_mathew Guest

    Default I have a problem with read from internal eprom

    im programming PIC 16f84a using pic basic pro

    i have 8 LEDs conected to the PORTB from 0 to 7...

    here is a problem...

    READ 0 , b 'on eprom location 0 is $AA

    PORTB = b

    its not working but this

    b = $AA

    PORTB = b

    is working...

    so what can i do to get this way working

    READ 0,b
    PORTB = B.......

  2. #2
    Join Date
    Oct 2005
    Posts
    14


    Did you find this post helpful? Yes | No

    Default

    how do you know adres 0 is filled with $AA ?

    do this

    write 0,$AA

    then the rest will work

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


    Did you find this post helpful? Yes | No

    Default

    if you used DATA to store your stuff, be sure your device programmer fill the internal EEPROM. Some device programmer software have the ability to enable/disable the EEPROM write to prevent loosing previous precious data.
    Steve

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

  4. #4
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by don_mathew
    ....
    its not working but this

    b = $AA

    PORTB = b

    is working...

    so what can i do to get this way working

    READ 0,b
    PORTB = B.......

    Once you store initial values into your eeprom then

    you can also do this:

    READ 0, PORTB



    ----------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  5. #5
    don_mathew's Avatar
    don_mathew Guest


    Did you find this post helpful? Yes | No

    Default

    reading from eprom is working but when i try to read 15address location and save them one by one in array its not working...this example is not working can enybody tell me what is wrong in this code...on PIC simulator IDE v6.34 on
    var led[15] led board gives me sign on PORTB $0F instead $FF

    define OSC 8

    TRISB = $00
    PORTB = $00


    i var byte

    led var byte [15]

    led[0] = %00000001
    led[1] = %00000010
    led[2] = %00000100
    led[3] = %00001000
    led[4] = %00010000
    led[5] = %00100000
    led[6] = %01000000
    led[7] = %10000000
    led[8] = %10000001
    led[9] = %10000010
    led[10] = %10000100
    led[11] = %10001000
    led[12] = %10010000
    led[13] = %10100000
    led[14] = %11000000
    led[15] = %11111111






    loop:

    for i = 0 to 15

    PORTB = led[i]

    Next i

    goto loop




    PIC16F84A

  6. #6
    don_mathew's Avatar
    don_mathew Guest


    Did you find this post helpful? Yes | No

    Default

    i found the problem...

    i'm c++ programmer and when u define array like this
    int var[15]

    that means var from 0 to 15 and thats 16 memory addresses

    and in pic basic

    led var byte [15] means from 0 to 14...i hope that this post will help someone...

  7. #7
    Join Date
    Jul 2005
    Posts
    78


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by don_mathew
    led var byte [15]
    That's your problem, you defined a 15 byte array and are trying to address the 16th element.

    led var byte [15] ' defines a 15 byte array addressed 0 to 14

    Change the 15 to a 16 and all should work.

  8. #8


    Did you find this post helpful? Yes | No

    Default

    If you define a 16 byte variable, is it the same thing as defining a word variable?

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


    Did you find this post helpful? Yes | No

    Default

    NOPE
    16 BITS will be a WORD.
    Steve

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

Similar Threads

  1. Cleaning up code
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd December 2009, 07:14
  2. write -read problem?
    By turkuaz in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 30th August 2009, 13:06
  3. SEROUT WORD variable problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th April 2009, 11:20
  4. Problem to read a PCF 8574
    By Darklakebridge7 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th February 2007, 21:56
  5. Changing declared variables names on the fly
    By jessey in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 16th December 2006, 06:34

Members who have read this thread : 0

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