Serin EEPROM Programmer


Results 1 to 12 of 12

Threaded View

  1. #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 04: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, 15:46
  2. Problem with I2C EEPROM addressing
    By Atom058 in forum General
    Replies: 14
    Last Post: - 3rd November 2009, 04:17
  3. Data EEPROM gets clobbered during programming
    By BrianT in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 18th July 2008, 03: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, 07:26
  5. word variable to 25lc640
    By TONIGALEA in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 6th July 2004, 20: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