Write and Read from eeprom


Results 1 to 24 of 24

Threaded View

  1. #21
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Try this out:

    Include "modedefs.bas" ' Include serial modes
    DEFINE OSC 4
    TRISA=$1b : trisb=$db : a var word : done var bit : x var byte : percent var byte : total var word : premios var word : cambio var word : mac var byte : t0 var total.byte0 : t1 var total.byte1
    p0 var premios.byte0 : p1 var premios.byte1 : c0 var cambio.byte0 : c1 var cambio.byte1 : coinout var portb.0 : coinin var portb.1 : done=0 : percent=50
    DISABLE
    GOSUB READIT
    loop:
    IF PORTB.6 = 1 THEN LLACONECTED
    IF COININ = 1 THEN COUNT1COIN
    IF COINout = 1 THEN COINOUT100 'this is the problem
    GOTO LOOP
    COUNT1COIN: PAUSE 20 : IF COININ=1 THEN COUNT1COIN
    TOTAL=TOTAL+1 : GOSUB WRITEIT:GOTO LOOP
    LLACONECTED: gosub readit : pause 500:for x=1 to 5:gosub info:next x : goto borrar
    BORRAR: SERIN2 PORTA.3,16780, 500,BORRAR,[WAIT ("CB"),DEC1 DONE]
    IF DONE=1 THEN BORRAR1
    IF DONE=0 THEN
    gosub info:gosub info:gosub info
    endif
    GOTO BORRAR
    BORRAR1: total=0 : premios=0:cambio=0:gosub writeit:for x=1 to 5 : gosub info:next x:goto loop
    writeit: write 0,t0:write 1,t1:write 2,p0:write 3,p1:write 4,c0:write 5,c1 : return
    readit: read 0,t0:read 1,t1:read 2,p0:read 3,p1:read 4,c0:read 5,c1:read 6,mac:return
    info: serout2 porta.2,16780,["M",dec3 mac] : pause 100:serout2 porta.2,16780,["T",dec5 total] : pause 100:serout2 porta.2,16780,["P",dec5 premios] : pause 100:serout2 porta.2,16780,["S",dec5 cambio]
    pause 100:return
    CNT: COUNTER=1:PAUSE 20:COUNTER=0:PAUSE 20:RETURN
    COINOUT100:
    PREMIOS=PREMIOS+1:if total > 0 then TOTAL=TOTAL-1
    GOSUB WRITEIT:GOTO LOOP
    END
    Last edited by skimask; - 9th June 2007 at 04:06. Reason: Fixed the colons and smiley faces :)

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. write -read problem?
    By turkuaz in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 30th August 2009, 13:06
  4. PIC16F684 + LCD to use the 256bytes of EEPROM - HELP
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 7th March 2008, 14:19
  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