View previous topic :: View next topic |
Author |
Message |
Rohit de Sa
Joined: 09 Nov 2007 Posts: 282 Location: India
|
CCS + PDFSUSB |
Posted: Thu Jul 19, 2012 2:33 am |
|
|
PIC18F2550, 20MHz, CCS 4.114
I've compiled and burned Microchip's CDC bootloader onto my '2550. However I'm having problems loading user code on the PIC with PDFSUSB. After staying up almost the whole night I whittled down the problem to this: the hex files being created are not 'proper'.
I'm using the CCS-C compiler though MPLAB.
My complete header: Quote: | #include <18F2550.h>
#use delay(clock=48000000)
#build(reset=0x800, interrupt=0x808)
#org 0x0000,0x07ff {} | The main program is just a simple blink for now.
This creates this hex file: Code: | :0408000018EF04F0F9
:08080800EA6A050EE96EEF50EB
:100810000EE00F0E016E006A002EFED7012EFBD7F0
:100820008F0E006E002EFED70000EF2EF2D7000CC8
:10083000F86AD09EEA6AE96AC150C00B0F09C16E1E
:10084000070EB46E93908A80C80E056EDDDF93901C
:0C0850008A90C80E056ED8DFF5D70300B3
:020000040030CA
:0E0000003FCF3E1E008781000FC00FE00F4073
:00000001FF
;PIC18F2550
;CRC=C9E3 CREATED="19-Jul-12 13:59" |
When loaded in PDFSUSB using the "load HEX file" button this is what I see in the window:
Why are the memory locations of the hex file being parsed wrong? PDFSUSB throws up no error and 'burns' the code. But on doing a read back it shows no code has been burnt (because the mem locations are out of range). On the other hand, after compiling the code, if I use MPLAB's 'export' function to export the HEX, I get something slightly different. This code parses and burns on PDFSUSB just fine. Code: | :020000040000FA
:1008000018EF04F0FFFFFFFFEA6A050EE96EEF50F4
:100810000EE00F0E016E006A002EFED7012EFBD7F0
:100820008F0E006E002EFED70000EF2EF2D7000CC8
:10083000F86AD09EEA6AE96AC150C00B0F09C16E1E
:10084000070EB46E93908A80C80E056EDDDF93901C
:0C0850008A90C80E056ED8DFF5D70300B3
:00000001FF |
Is this an issue with MPLAB, or the compiler, or PDFSUSB?
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19513
|
|
Posted: Thu Jul 19, 2012 7:15 am |
|
|
Do you know if the program requires 8bit hex, or 16bit hex format?.
CCS can generate both, using the command line options "+O8xxx", or "+OWxxx".
Do a 'save hex', from the PDFSUSB program, and see which format it generates, then set CCS to generate the same.
Best Wishes |
|
|
Rohit de Sa
Joined: 09 Nov 2007 Posts: 282 Location: India
|
|
Posted: Thu Jul 19, 2012 7:32 am |
|
|
Read back working code from the chip. The first line of the hex file is So this is a INHX32 file right?
This is what the compiler/MPLAB generates: Code: | :0408000019EF04F0F8 | Also INHX32 format if I'm not wrong.
I've already tried both the command line switches. Neither gives me the correct results. For now, I'm just using the 'Export' alternative, but this is really irritating since I have to always select the memory range and other options before exporting.
Funny thing is - I've used CCS with PDFSUSB before (about a year ago) and this worked absolutely fine. Only, I don't remember which compiler version/MPLAB version/PDFSUSB version works fine at that time. |
|
|
Rohit de Sa
Joined: 09 Nov 2007 Posts: 282 Location: India
|
|
Posted: Thu Jul 19, 2012 8:08 am |
|
|
So, I've checked the hex files generated with two utilities
https://github.com/codinghead/Intel-HEX-Class/downloads and hexmate from HiTech http://www.schmalzhaus.com/Tools/HexmateInstructions.html
Faulty hex: Code: | :0408000018EF04F0F9
:08080800EA6A050EE96EEF50EB
:100810000EE00F0E016E006A002EFED7012EFBD7F0
:100820008F0E006E002EFED70000EF2EF2D7000CC8
:10083000F86AD09EEA6AE96AC150C00B0F09C16E1E
:10084000070EB46E93908A80C80E056EDDDF93901C
:0C0850008A90C80E056ED8DFF5D70300B3
:020000040030CA
:0E0000003FCF3E1E008781000FC00FE00F4073
:00000001FF
;PIC18F2550
;CRC=C9E3 CREATED="19-Jul-12 13:59" |
Both utilities tell me that the first 11 lines have a bad checksum. The file compiles fine, but the hex generated is faulty. This is my code: Code: | #include <18F2550.h>
#use delay(clock=48000000)
#build(reset=0x800, interrupt=0x808)
#org 0x0000,0x07ff {}
void main (void)
{
while(true)
{
output_low(pin_b0);
delay_ms(200);
output_high(pin_b0);
delay_ms(200);
}
} |
Could someone please compile this code and post the hex file. Select device as PIC18F2550, config bits set in code.
Appreciate the trouble! |
|
|
Rohit de Sa
Joined: 09 Nov 2007 Posts: 282 Location: India
|
|
Posted: Sat Jul 21, 2012 7:01 am |
|
|
So I'm getting somewhere with this. I've kinda-sorta-maybe figured out how to fix this issue, but I'll need to play around with it more. Apparently PDFSUSB has an issue with parsing addresses generated by CCS-C and HiTech-C. On this thread http://www.microchip.com/forums/tm.aspx?high=&m=212783&mpage=1#665743 the poster Jan mentioned earlier, that 'proper' files start with So we have to convert the files into a format parse-able by PDFSUSB.
This post simply suggests editing the hex file and adding ":020000040000FA" to the cod right at the top. This did NOT work for me.
http://www.picprojects.ne.usbbootloader/index.html
This post also talks about a similar issue:
https://www.microchip.com.orums/m637968-print.aspx It suggests that the program 'hexmate' may be of help. Hexmate gets installed with HiTech-C compiler as one of the utilities.
http://forum.htsoft.com/a...topic=&Search=true
I used hexmate through a command line to convert my hex file to INHX032 format, which PDFSUSB can now parse properly. I used the command: Code: | hexmate wrong.hex -format=INHX032 -Ocorrect.hex | That's 'INHX-zero-32', and '-O-for-orange-correct.hex'
I'm going to try calling hexmate from the CCS-C compiler's command line by appending to the optional switches. Or I may probably have to create a batch file to do this automatically. Dirty solution, but it may work. |
|
|
|