Serin EEPROM Programmer


Closed Thread
Results 1 to 12 of 12

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default pic12f683

    I am using the pic12f683

  2. #2
    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

  3. #3
    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

  4. #4
    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.

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


    Did you find this post helpful? Yes | No

    Default

    Since you made variable addr a word then you have to change your serin command to receive two bytes to be combined into one word. This means you have to Tx two bytes (SERIN is unable to receive word)


    Code:
    serin sein, 6, addr
    
    serin sein, 6, addr.byte0,addr.byte1
    Al.
    Last edited by aratti; - 24th February 2010 at 19:15.
    All progress began with an idea

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


    Did you find this post helpful? Yes | No

    Default Reply

    I have decided to narrow it down just to the SERIN command. I made a program to read the serial command from the pc and then transmit it back to the pc. When I send the serial data to the pic the transmit light flashes so I know the pc is sending the serial data but the pic is not retransmitting it back to the pc. I am using the debug terminal from the basic stamp program and Parallax USB2SER Development Tool.


    Code:
    val var byte
    
    TRISIO = %00000010
    
    main:
        serin GPIO.1, 6, [val]
        pause 10
        serout GPIO.2, 6, [val]
        pause 10
    goto main

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


    Did you find this post helpful? Yes | No

    Default

    SERIN doesn't need square bracket. Within bracket you will place the qualifier, not the variable.

    Code:
     
    serin GPIO.1, 6, [val]
    
     serin GPIO.1, 6, val
    Al.
    Last edited by aratti; - 24th February 2010 at 21:01.
    All progress began with an idea

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