Internal Eeprom/flash , what are you doing ?


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Apr 2006
    Location
    GearSweaterMountain, The Netherlands
    Posts
    52

    Default Internal Eeprom/flash , what are you doing ?

    Hi there,

    New problem. Eeprom doesn't seem to 'store' values. What is going on ?
    Due to the fact that i could'nt get the eeprom part of my code to work, i changed the program to read value, increment, write value and flash led 'value' times. Every time i apply Vdd the value in eeprom should be 1 more then before. Unfortunately, this code always flashes twice, what's going on ?

    Code:
    '==== Set fuses =============================================
    @ device  pic12F519, intrc_osc, wdt_off, mclr_off, ioscfs_off, protect_off, cpdf_off
    
    '==== Set defines ============================================
    DEFINE OSC 8                                            'Int OSC @ 8 Mhz
    OPTION_REG = %10000000
    
    '==== Set variables ===========================================
    Y       VAR word                                        '
    TMP     var BYTE                                        'Temp variable
    tmp2    var byte                                         'Temp variable
    
    
    '==== Set IO ================================================    
    TRISB   = %00111100                                     'Set TRIS register input's & output's
    PORTB   = %00000000                                     'Set all digital low
    led     var PORTB.0                                     'led pin
    
    '==== Main program ===========================================
    MAIN:
    pause 400
    
    read 1,tmp            'read previously written value
    pauseus 100
    
    tmp = tmp + 1        'increment value
    
    write 1,tmp            'store new value
    pauseus 100
    
    tmp2 = 0
    for tmp2 = 0 to tmp
        led = 1
        pause 300
        led = 0
        pause 700
    next tmp2
    
    pause 500
    
    theend:
    goto theend
    Anybody ??

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Increase the pause time after the writes to about 10ms, not 100us...just like the book says...

  3. #3
    Join Date
    Apr 2006
    Location
    GearSweaterMountain, The Netherlands
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Skimask, hi !

    I tried the 10ms delays after read and write, but still no results, keep getting those 2 flashes.
    When i read back the hex location 0x400 always reads 0001 (1 flash one 0, and one on 1, two flashes)

    I have changed the code a little bit to let the variable increment whilst the power is on to be sure it increments, but after power off, power on, again two flashes ...

    Here's the code:
    Code:
    '==== Set fuses ============================================
    @ device  pic12F519, intrc_osc, wdt_off, mclr_off, ioscfs_on, protect_off, cpdf_off
    
    '==== Set defines =========================================
    OPTION_REG = %10000000
    
    '==== Set variables ============================================
    Y       VAR word                                        'To Hold the 12-bit RC5 code
    TMP     var BYTE                                        'Temp variable
    tmp2    var byte
    
    
    '==== Set IO =================================================    
    TRISB   = %00111100                                     'Set TRIS register input's & output's
    PORTB   = %00000000                                     'Set all digital low
    led     var PORTB.0                                     'led pin
    
    '==== Main program ============================================
    MAIN:
    pause 400
    tmp = 0
    
    read 0,tmp
    pause 10
    if tmp > 50 then tmp = 1
    if tmp < 1 then tmp = 1
    
    again:
    tmp = tmp + 1
    write 0,tmp
    pause 10
    tmp2 = 0
    
    for tmp2 = 1 to tmp
        led = 1
        pause 200
        led = 0
        pause 400
    next tmp2
    
    pause 2000
    goto again
    end
    What is wrong, here ?

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Code:
    @ device pic12F519, intrc_osc, wdt_off, mclr_off, ioscfs_on, protect_off, cpdf_off
    option_reg=$80 : tmp var byte : tmp2 var byte : ledtmp var byte
    badflag var bit : trisb = $3c : portb=0 : led var portb.0
    main: badflag = 0 : for tmp=0 to 63 : write tmp,tmp : pause 10 : read tmp,tmp2
    if tmp<>tmp2 then gosub flashbad
    next tmp : if badflag = 0 then gosub flashgood
    goto main
    flashbad:  badflag = 1 : for ledtmp=0 to 9 : led=1 : pause 50 : led=0
    pause 50 : next ledtmp : return
    flashgood: for ledtmp=0 to 9 : led=1 : pause 500 : led=0 : pause 500
    next ledtmp : return
    end
    Code will write the value into the eeprom location, then read it back, stepping thru each eeprom location in the '519.
    If the readback doesn't match what was written, the led will flash fast 10 times.
    If the readback is good, it'll flash slowly 10 times after the loop is complete, then start over...

  5. #5


    Did you find this post helpful? Yes | No

    Default

    I don't know if this has anything to do with it but it looks like the PIC doesn't have portb. It has GPIO's. Try changing portb.0 to gpio.0 and trisb to trisio.

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by peterdeco1 View Post
    I don't know if this has anything to do with it but it looks like the PIC doesn't have portb. It has GPIO's. Try changing portb.0 to gpio.0 and trisb to trisio.
    That was discussed in another thread earlier today...
    Apparently, PBP aliases GPIO to PORTB and TRISIO to TRISB for the 12F519...
    Go figure eh? I wouldn't have found that... Handy though...

Similar Threads

  1. Internal vs. external osc for comms
    By mtripoli in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 29th January 2010, 14:58
  2. 12F683 internal pull up
    By hvacrtech in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 27th July 2008, 02:35
  3. Use internal program memory like DATA memory
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th December 2006, 18:38
  4. 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
  5. 12f675 internal osc question.....
    By Gabe@SPdFtsh in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 6th January 2004, 06:33

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