Thanks pedja089, that's awesome - is that using an 18F PIC? Do you know if this can be done using the 16F1xxx series? From what I've read, the DEFINE RESET ORG option is only functional on the 18's - does that sound right?
Can anyone else confirm?
Thanks pedja089, that's awesome - is that using an 18F PIC? Do you know if this can be done using the 16F1xxx series? From what I've read, the DEFINE RESET ORG option is only functional on the 18's - does that sound right?
Can anyone else confirm?
I use 18F series for all my project.
You can just compile some code for 16F, something like
DEFINE RESET_ORG 16
pause 1
And you should get 16 bytes FF then some other values. Also to view content of hex file you could use any programmer software, but I prefer MPLAB X, because I can export HEX values of just piece of hex to text file, and format it to ASM sintax.
Then let us know
I don't know what 16F part are able to do flash write. And also flash size is critical.
So I think any way, better to go with some 18F that have twice flash you need, so you could use flash to flash bootloader. It's really neat, small, simple and doesn't require any external parts!
All this can be done in ASM to get even smaller bootloaders, but I just didn't bother with that.
By the way all 18F can do code erase, write and read eaven if it is locked. Code protect bit affect only ICSP.
This is definitely a great starting point. I'll test with some simple stuff and then see how it works out on the PIC I'm using. Might be just what I needed.
picster
Ok so looking at the code, I had a couple of questions - I'm hoping you can clarify for me.
1) Flashbyte2 and Flashbyte3 - redundant copies, with the same data 3 times in i2c eeprom?
2) What is the purpose of EraseStr VAR BYTE[128]? I don't see it elsewhere in the pasted code.
3) Lastly, in the ASM portion, you start each line with dw - is this just to "define words" (hex format little-endian) that will simply sit there in memory until you jump to the label?
I really appreciate your posting this, it's hugely helpful.
Picster
Last edited by picster; - 5th May 2016 at 01:27. Reason: amended question
1) Redundant read of same memory location. Just to be sure that there is no error in communication. Same at writing, write 32 bytes, then read them, and compare. Just to on safe side.
2) Scroll little bit down
Just easy way to dump 128 zeros in memory.Code:'Optional Erase I2C EEPROM FOR Adr=0 TO 79999 STEP 128 MAdr=Adr.WORD0 MCtrl=$A0 + ((Adr.BYTE2 & %00000011)<<1) BootI2CW: I2CWRITE Mem_Sda,Mem_Scl,MCtrl,MAdr,[STR EraseStr\128],BootI2CW PAUSE 5
3) Not sure what you are asking, but that is code for bootloader in main app. That code will sit there forever. And execute when jump to label.
Output of first 32 line from random project in MPLAB X program windows(right click output to file)
Similar thing you will get when compile bootloader, but at different start address. And you need to copy opcode column to to your main program and address must lineup.Code:Line Address Opcode Label DisAssy 1 00000 EF30 GOTO 0x260 2 00002 F001 NOP 3 00004 FFFF NOP 4 00006 FFFF NOP 5 00008 0012 RETURN 0 6 0000A FFFF NOP 7 0000C FFFF NOP 8 0000E FFFF NOP 9 00010 FFFF NOP 10 00012 FFFF NOP 11 00014 FFFF NOP 12 00016 FFFF NOP 13 00018 0012 RETURN 0 14 0001A 010F HSEROUT MOVLB 0xF 15 0001C 0004 hseroutloop CLRWDT 16 0001E A89E BTFSS PIR1, 4, ACCESS 17 00020 D7FD BRA hseroutloop
I'm not sure that I answered your question.
Got it, thanks.
Makes sense
picster
Great!
Did you try to compile code for 16F with RESET_ORG?
Bookmarks