ICP via optocouplers?


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Sep 2009
    Posts
    755


    Did you find this post helpful? Yes | No

    Default Re: ICP via optocouplers?

    You don't need reset for bootloader. Why bootloader must start first?
    I always load hex file via main app in external eeprom, or in upper half of PIC FLASH memory.
    In main app there is already all you need to connect to PC or whatever. So use that to load HEX from PC.
    Code:
        INTCON=0
        FOR Adr=32768 TO 65023 STEP BlockSize
            ERASECODE Adr
        NEXT Adr
        FOR Adr=0 TO 32255
            Err=0
            FwReceive:
            Err=Err+1
            IF Err=250 THEN
                GOTO DeliteAndReset
            ENDIF
            HSEROUT2 ["A:",DEC6 Adr,3]
            HSERIN2 100, FwReceive, [WAIT("D:"), Tmp0, Tmp1]
            IF Tmp0<>Tmp1 THEN GOTO FwReceive
            Adr.15=1
            WRITECODE Adr,Tmp0
            Adr.15=0
        NEXT Adr
        GOTO StartBootloader
    And at end of code there is bootloader that copy from upper half to a lower half of FLASH. That bootloader is precompiled.
    Code:
    @ ORG .65024
    StartBootloader:
    ASM
     dw 0EF3Dh, 0F07Fh, 06EF6h, 06AF8h, 00E94h, 06E7Fh, 00E55h, 06E7Eh, 00EAAh, 06E7Eh, 0827Fh, 00000h, 0947Fh, 0EF3Ah, 0F07Fh, 06AF8h 
     dw 00E80h, 06E7Fh, 00009h, 050F5h, 0EF3Ah, 0F07Fh, 06AF8h, 06EF5h, 0000Ch, 028F6h, 00B3Fh, 0E109h, 00E84h, 06E7Fh, 00E55h, 06E7Eh 
     ETC...
    Code for that is:
    Code:
    DEFINE RESET_ORG .65024
    
    Adr VAR WORD
    Tmp VAR BYTE
    BlockSize       VAR BYTE BANKA SYSTEM
    @ MovLW BLOCK_SIZE
    @ MovWF BlockSize
    
    FOR Adr=0 TO 32255 STEP BlockSize
        ERASECODE Adr
    NEXT Adr
    
    FOR Adr=0 TO 32255 'Ne diraj zadnjih 512B
        Adr.15=1
        READCODE Adr,Tmp
        Adr.15=0
        WRITECODE Adr,Tmp
    NEXT Adr
    @ RESET
    EDIT:
    Hope that this is not too confusing...
    EDIT2:
    Last edited by pedja089; - 22nd March 2016 at 17:41.

Similar Threads

  1. Labx2 icp problem .. help please
    By DavidFMarks in forum Schematics
    Replies: 5
    Last Post: - 8th December 2007, 17:23

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