Read write word and Hserin


Closed Thread
Results 1 to 1 of 1
  1. #1
    Join Date
    Oct 2008
    Posts
    13

    Default Read write word and Hserin

    i confused about my code not working correctly 16f688 with 20 mhz
    in first time fill eeprom 254 location with 127 word from rs232 serin data before save it compare
    eeprom stored data if no data is same its store if same its not store
    and other is if dat word is match led is on also led on by manually by pressing switch one button is for storege [sorry for my bad enlish]
    mycode is :



    @ DEVICE PIC16F688, HS_OSC, WDT_ON, PWRT_OFF, MCLR_OFF, BOD_OFF,PROTECT_OFF
    DEFINE OSC 20
    RCSTA = $90 ' Enable serial port & continuous receive
    TXSTA = $24 ' Enable transmit, BRGH = 1
    SPBRG = 9 ' 115200 Baud @ 18.432MHz, 0.0%
    Ctr_A VAR Byte
    WR_ERORR VAR Bit
    datain VAR Byte[8]
    C_Led VAR PORTA.0
    LED VAR PORTA.1
    IN VAR PORTA.2
    STORE_BUT VAR PORTA.3
    DAT_A VAR Word
    ADDRESS_COUNT VAR Byte
    BACK_DATA VAR Word
    ADDRESS VAR Byte
    MAIN:
    HSerIn [Wait($07), Str datain\8]
    DAT_A = datain[0]+datain[1]+datain[2]+datain[3]+datain[4]+datain[5]+datain[6]+datain[7]
    If IN = 1 Then Toggle LED
    For ADDRESS = 1 To 255 Step 2
    Read ADDRESS ,BACK_DATA
    If BACK_DATA = DAT_A Then
    WR_ERORR =1
    Else
    WR_ERORR =0
    EndIf
    If WR_ERORR =1 Then GoTo LIGHT
    Next

    LIGHT:
    WR_ERORR =LED

    If STORE_BUT = 0 Then GoTo MAIN
    PAUSE 50
    If STORE_BUT = 1 And WR_ERORR = 0 Then GoTo STORE_IT
    For Ctr_A = 0 To 4
    Toggle C_Led
    PAUSE 150
    Next Ctr_A
    GoTo MAIN
    STORE_IT:
    Read 0 ,ADDRESS_COUNT
    ADDRESS_COUNT=ADDRESS_COUNT+2
    Write ADDRESS_COUNT,DAT_A
    For Ctr_A = 0 To 10
    Toggle C_Led
    PAUSE 90
    Next Ctr_A
    Write 0,ADDRESS_COUNT
    GoTo MAIN
    End
    Last edited by aa222k; - 1st December 2011 at 19:32.

Members who have read this thread : 1

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