PIC12F683 and EEPROM


Closed Thread
Results 1 to 3 of 3

Hybrid View

  1. #1
    Join Date
    May 2010
    Posts
    20

    Default PIC12F683 and EEPROM

    Hi everyone,

    I have a PIC12F683 which communicates via serin/serout and I want it to be able to store an 8 digit number into eeprom. I have searched and searched and I can't find any basic examples on how I can read write something like for example "47364837" sent over serial port to eeprom. Can anyone point me in the right direction please. Just thought it would be a fun project to help me learn

    Thanks,
    Ross

    Edit: I probably should have put this under Picbasc Pro forum - doh. My brain is fried from googling this issue. Sorry
    Last edited by ross246; - 19th November 2010 at 16:42.

  2. #2
    Join Date
    May 2010
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    Ok figured out the EEPROM thing kind of - works fine when working with a single digit Just need to know how I can store a string of numbers and then return it on demand. Code so far:

    Code:
    Include "modedefs.bas"
    
    OSCCON = %01100000      'set for 4mhz internal
    CMCON0 = 7              'TURN COMPARITORS OFF
    ANSEL  = %00000000      'Set A/D OFF
    ADCON0 = %00000000      'Analog converter OFF 
    TRISIO = %00000000        'Set GSIO 4 and 2 to INPUT, others to OUTPUT
    
    tcx var GPIO.0 'output pin
    rcx var GPIO.1 'input pin
    led VAR GPIO.5 
    cmd VAR byte
    x   VAR BYTE        
    
    Main:
    serin rcx,n2400,cmd 
     If cmd = "0" THEN GOTO SetNum
     If cmd = "1" THEN GOTO RetNum
    GOTO Main
    
    setNum:
    serin rcx,n2400,x 
    WRITE 2, x
    GOTO Main
    
    RetNum:
    READ 2, x
    SEROUT tcx,n2400,[x]
    goto main

  3. #3
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default

    I know there are more elegent ways of doing this but as a starting point to learn I would suggest this:
    Each byte received needs to have somewhere to go like the first character you did so make some more variables for the rest.
    Code:
    X0 VAR BYTE
    ....
    X7 VAR BYTE
    
    setnum:
    SERIN rcx,n2400,X0,X1,X2,X3,X4,X5,X6,X7
    WRITE 2, X0   ' Remember this takes some time, about 10ms ea
    WRITE 3, X1
    ...
    WRITE 9, X7
    GOTO main
    
    RetNum:
    READ 2, X0
    READ 3, X1
    ...
    READ 9, X7
    SEROUT tcx,n2400,[x0,X1,X2,X3,X4,X5,X6,X7]
    goto main.
    I haven't tested this but I hope you get the idea.
    Louie

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