CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

CCS + PDFSUSB

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Rohit de Sa



Joined: 09 Nov 2007
Posts: 282
Location: India

View user's profile Send private message Visit poster's website

CCS + PDFSUSB
PostPosted: Thu Jul 19, 2012 2:33 am     Reply with quote

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?

Mad
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Thu Jul 19, 2012 7:15 am     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Thu Jul 19, 2012 7:32 am     Reply with quote

Read back working code from the chip. The first line of the hex file is
Code:
:020000040000FA
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

View user's profile Send private message Visit poster's website

PostPosted: Thu Jul 19, 2012 8:08 am     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Sat Jul 21, 2012 7:01 am     Reply with quote

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
Code:
:020000040000FA
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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group