Serin EEPROM Programmer


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Feb 2010
    Location
    Albuquerque
    Posts
    19

    Default Serin EEPROM Programmer

    I have spent two days trying to figure this out. I have a feeling it has to do with the SERIN command. Please help.
    ------------------------------------------------------------------------
    define OSC 4
    Define CHAR_PACING 500

    CMCON0 = 7
    ANSEL = %00000000

    cont con %10100000
    scl var GPIO.5
    sda var GPIO.4
    sout var GPIO.2
    sein var GPIO.1
    addr var byte
    wr var byte
    val var byte

    Main:

    serout sout, 6, ["To write to EEPROM press w", 13, "To read EEPROM press r", 13]
    serin sein, 6, wr
    if (wr = "w") then goto ewrite
    if (wr = "r") then goto eread
    goto main

    ewrite:

    serout sout, 6, ["Write", 13]
    serout sout, 6, ["Enter address 0 - 15", 13]
    serin sein, 6, addr
    serout sout, 6, ["Enter value 0 - 255", 13]
    serin sein, 6, val

    i2cwrite sda, scl, cont, addr, [val]
    pause 10

    serout sout, 6, ["Write complete", 13]
    goto main

    eread:

    serout sout, 6, ["Read", 13]
    serout sout, 6, ["Enter address 0 - 15", 13]
    serin sein, 6, addr

    i2cread sda, scl, cont, addr, val
    pause 10

    serout sout, 6, [#val, 13]
    serout sout, 6, ["Read complete", 13]
    goto main
    ------------------------------------------------------------------------

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hello dirtbiker. . .
    Welcome to the forum.
    Please Give us a hint, which PIC are you using?
    Just right off the top of my bald head . . .
    TRISIO=%00000010
    Last edited by Archangel; - 23rd February 2010 at 05:01.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    Feb 2010
    Location
    Albuquerque
    Posts
    19


    Did you find this post helpful? Yes | No

    Default pic12f683

    I am using the pic12f683

  4. #4
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Code:
    i2cread sda, scl, cont, addr, val
    
    i2cread sda, scl, cont, addr,[val]
    Additionally variable addr must be a word not a byte!

    Al.
    All progress began with an idea

  5. #5
    Join Date
    Feb 2010
    Location
    Albuquerque
    Posts
    19


    Did you find this post helpful? Yes | No

    Default Reply

    I changed TRISIO, put brackets around the [val] variable and changed addr to a word sized variable .When I start up the microcontroller it sends the first serial out command to the computer but when I send a serial command to the microcontroller from the pc the microcontroller goes into a loop and repeats the first serial command non stop until I disconnect the power.

    Code:
    define OSC 4
    Define CHAR_PACING 1000
    
    CMCON0 = 7
    ANSEL  = %00000000
    TRISIO = %00000010
    
    cont  con %10100000
    scl   var GPIO.5
    sda   var GPIO.4
    sout  var GPIO.2
    sein  var GPIO.1
    addr  var word
    wr    var byte
    val   var byte
    
    Main:
    
    serout sout, 6, ["To write to EEPROM press w", 13, "To read EEPROM press r", 13]
        serin sein, 6, wr
        if (wr = "w") then goto ewrite 
        if (wr = "r") then goto eread
        goto main 
                   
    ewrite:
    
    serout sout, 6, ["Write", 13]
    serout sout, 6, ["Enter address 0 - 15", 13]
    serin sein, 6, addr
    serout sout, 6, ["Enter value 0 - 255", 13] 
    serin sein, 6, val
    
    i2cwrite sda, scl, cont, addr, [val]
    pause 10
    
    serout sout, 6, ["Write complete", 13]
    goto main
    
    eread:
    
    serout sout, 6, ["Read", 13]
    serout sout, 6, ["Enter address 0 - 15", 13]
    serin sein, 6, addr
    
    i2cread sda, scl, cont, addr, [val]
    pause 10
    
    serout sout, 6, [#val, 13]
    serout sout, 6, ["Read complete", 13]
    goto main

  6. #6
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by dirtbiker5627 View Post
    I changed TRISIO, put brackets around the [val] variable and changed addr to a word sized variable .When I start up the microcontroller it sends the first serial out command to the computer but when I send a serial command to the microcontroller from the pc the microcontroller goes into a loop and repeats the first serial command non stop until I disconnect the power.

    Code:
    define OSC 4
    Define CHAR_PACING 1000
    
    CMCON0 = 7
    ANSEL  = %00000000
    TRISIO = %00000010
    
    cont  con %10100000
    scl   var GPIO.5
    sda   var GPIO.4
    sout  var GPIO.2
    sein  var GPIO.1
    addr  var word
    wr    var byte
    val   var byte
    
    Main:
    
    serout sout, 6, ["To write to EEPROM press w", 13, "To read EEPROM press r", 13]
        serin sein, 6, wr
        if (wr = "w") then goto ewrite 
        if (wr = "r") then goto eread
        goto main 
                   
    ewrite:
    
    serout sout, 6, ["Write", 13]
    serout sout, 6, ["Enter address 0 - 15", 13]
    serin sein, 6, addr
    serout sout, 6, ["Enter value 0 - 255", 13] 
    serin sein, 6, val
    
    i2cwrite sda, scl, cont, addr, [val]
    pause 10
    
    serout sout, 6, ["Write complete", 13]
    goto main
    
    eread:
    
    serout sout, 6, ["Read", 13]
    serout sout, 6, ["Enter address 0 - 15", 13]
    serin sein, 6, addr
    
    i2cread sda, scl, cont, addr, [val]
    pause 10
    
    serout sout, 6, [#val, 13]
    serout sout, 6, ["Read complete", 13]
    goto main
    Where does it go if wr<>r and <> w?
    Main
    Give yourself a third option to gather serial data, if wr has z in it and never receives the r or w or receives R or W
    it will loop in main forever. You could serout sout,6,[" I received ",#wr] so you know what it got . . .
    Last edited by Archangel; - 24th February 2010 at 03:56.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. Can't read sequential addresses in external EEPROM
    By tjkelly in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th February 2010, 14:46
  2. Problem with I2C EEPROM addressing
    By Atom058 in forum General
    Replies: 14
    Last Post: - 3rd November 2009, 03:17
  3. Data EEPROM gets clobbered during programming
    By BrianT in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 18th July 2008, 02:46
  4. How to write/read strings EEPROM/LCD
    By g-hoot in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 11th February 2007, 06:26
  5. word variable to 25lc640
    By TONIGALEA in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 6th July 2004, 19:59

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