mode interruption de 16f876a
I'll try to recap before it sinks away.
You start with the 2 files in the icd directory: ICD2_4550_BOOT_0180.bin & ICD2_4550_OS_0100.bin. The OS file does not need any changes (for now), the BOOT file needs be to converted to a hex file, and needs to be modified.
Convert the BOOT file to a HEX file with a utility bin2hex.exe, which you can find on the net.
bin2hex /O0x80 BOOT.BIN
- It's a DOS utility so dont use long filenames.
- The BIN data should be loaded at address 0x0080, therefor the option "/O0x80"
Now there is a BOOT.HEX which you can import into MPLAB. You should see:
Code:
0080 434D RRNCF 0x4d, F, BANKED
...
1FDC EE17 LFSR 0x1, 0x700
...
It needs 2 changes:
- Reset & interrupt vectors have to be added
- Register at 0xF0 needs to be cleared
Code:
0000 0100 MOVLB 0
0002 6BF0 CLRF 0xF0, BANKED
0004 EFEE GOTO 0x1dfc
..
0008 GOTO 0x2808
..
0018 GOTO 0x1f9c
Somehow MPLAB does not let you enter "CLRF Oxf0, BANKED", you'll have to edit the opcode.
Now the file can be programmed in your 4550 (or 2550,2455..), and it should enumerate as an ICD2. Config settings are straight foreward, USB on, the correct PPLDIV for your crystal and let the CPU run at 48Mhz.
The hardware for the bootloader:
- a LED at RC1 (optional)
- RA4 should be low
- RB7 should be high
I'm not sure about the function of RA4. When its high the bootloader just goes into an endless loop flashing RC1.
RB7 is the "force bootload" switch. During normal operation the bootloader should only do a "GOTO 0x2800" to start the OS. However it will not do this if one of 3 conditions is true:
- RB7 is low, bootload requested by hardware
- Reg 0xF0!=0, bootload requested by software(??)
- No OS loaded yet, sum of all bytes in 0x2800-end should be 0 for a valid OS
The first time it is started there will be no OS so the bootloader will keep running. When you connect to it in MPLAB the OS will be downloaded, the bootloader will restart and... ding-dong, the OS will be started.
Now you have connect the OS to the 877, which I never did. I only remember you need to connect PORTD to PORTD. Maybe someone else can continue from here..
There is still a problem where the program in the 4550 gets corrupted after a quick disconnect/reconnect. It's annoying and hard to reproduce so not much fun investigate.
Manuel: The labels were added "auto-manually"
Added after 13 minutes:
I never built a PICKIT but I am using it's charge-boost example for Vpp. It needs a PWM output. This can be combined with a 877 but it requires a modified (rewritten) OS for the 4550.