AnsweredHot!HEX file size

Author
azharudheen_md
New Member
  • Total Posts : 24
  • Reward points : 0
  • Joined: 2017/03/29 06:16:41
  • Location: 0
  • Status: offline
2017/10/05 01:16:09 (permalink)
0

HEX file size

Hi All,
I am using PIC16F877A. Flash memory is 8kb and as per the concept of 1byte has 14bit wide memory locations. Hence, (8192*14)/8=14.3K. As per the calculations I will be able to dump/download/flash any .HEX with size<14.
 
In my case I have an .HEX sized 16K and it is working fine.
 
Can someone explain what actually is?
 
 
Thank you
#1
1and0
Access is Denied
  • Total Posts : 7310
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: HEX file size 2017/10/05 02:03:18 (permalink) ☼ Best Answerby azharudheen_md 2017/10/09 03:53:53
+3 (3)
azharudheen_md
I am using PIC16F877A. Flash memory is 8kb and as per the concept of 1byte has 14bit wide memory locations. Hence, (8192*14)/8=14.3K. As per the calculations I will be able to dump/download/flash any .HEX with size<14.
 
In my case I have an .HEX sized 16K and it is working fine.
 
Can someone explain what actually is?

Each PIC16 instruction is 14 bit wide, represented using 4 hex digits or 4 bytes in the hex file. A typical line of the hex file represents 16 data bytes or 8 instructions words.
 
A typical line of the hex file consists of a colon (1 byte), byte count (2), address (4), record type (2), data bytes (32 for 8 instruction words), checksum (2), and end-of-line (2). That is a total of 45 bytes per record line, representing 8 instruction words. For 8K bytes words of flash memory, that would be 1024 lines and takes about 46K bytes. Adding the records for EEPROM, ID locations, config bits, etc. a hex file for the entire chip takes about 47K - 48K bytes.
 
post edited by 1and0 - 2017/10/05 02:18:08
#2
qhb
Superb Member
  • Total Posts : 6257
  • Reward points : 0
  • Joined: 2016/06/05 14:55:32
  • Location: One step ahead...
  • Status: offline
Re: HEX file size 2017/10/05 02:03:26 (permalink)
+2 (2)
You're calculations are way off.
A hex file is an ASCII representation of the data, so it takes 4 bytes to represent each word in the memory.
There is also a lot of other overhead in a hex file.
Have a read at https://en.wikipedia.org/wiki/Intel_HEX
 
 
#3
azharudheen_md
New Member
  • Total Posts : 24
  • Reward points : 0
  • Joined: 2017/03/29 06:16:41
  • Location: 0
  • Status: offline
Re: HEX file size 2017/10/06 23:01:10 (permalink)
0
Thank You 1and0.
 How you determined that PIC16 has 1024 lined in flash memory? Please explain
If you explain the same for 18f45k22. It would be helpful and I can co relate each other and understand it once for good.
post edited by azharudheen_md - 2017/10/06 23:08:36
#4
NKurzman
A Guy on the Net
  • Total Posts : 15347
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: offline
Re: HEX file size 2017/10/06 23:39:33 (permalink)
+1 (1)
Abyte is 8 bits. A Word for your pic is 14 bits.
You can look up the "Intel Hex" file format. It will explain why the file it so much bigger than the hex image it contains.
#5
qhb
Superb Member
  • Total Posts : 6257
  • Reward points : 0
  • Joined: 2016/06/05 14:55:32
  • Location: One step ahead...
  • Status: offline
Re: HEX file size 2017/10/07 03:04:50 (permalink) ☄ Helpfulby azharudheen_md 2017/10/07 05:50:26
+1 (1)
azharudheen_md
... How you determined that PIC16 has 1024 lined in flash memory? Please explain

That's not what he said. Pay attention to the words.
 
1and0
Each PIC16 instruction is 14 bit wide, represented using 4 hex digits or 4 bytes in the hex file. A typical line of the hex file represents 16 data bytes or 8 instructions words.
... 
A typical line of the hex file consists of a colon (1 byte), byte count (2), address (4), record type (2), data bytes (32 for 8 instruction words), checksum (2), and end-of-line (2). That is a total of 45 bytes per record line, representing 8 instruction words. For 8K bytes words of flash memory, that would be 1024 lines 
...

So, 1024 is simply 8k (words of flash) divided by 8 (words per line in the hex file)
which is how many lines in the hex file are required to represent 8k words of FLASH memory.
 
#6
azharudheen_md
New Member
  • Total Posts : 24
  • Reward points : 0
  • Joined: 2017/03/29 06:16:41
  • Location: 0
  • Status: offline
Re: HEX file size 2017/10/07 05:45:14 (permalink)
0
.
post edited by azharudheen_md - 2017/10/07 05:55:31
#7
azharudheen_md
New Member
  • Total Posts : 24
  • Reward points : 0
  • Joined: 2017/03/29 06:16:41
  • Location: 0
  • Status: offline
Re: HEX file size 2017/10/07 05:54:54 (permalink)
0
qhb
azharudheen_md
... How you determined that PIC16 has 1024 lined in flash memory? Please explain

That's not what he said. Pay attention to the words.
 
1and0
Each PIC16 instruction is 14 bit wide, represented using 4 hex digits or 4 bytes in the hex file. A typical line of the hex file represents 16 data bytes or 8 instructions words.
... 
A typical line of the hex file consists of a colon (1 byte), byte count (2), address (4), record type (2), data bytes (32 for 8 instruction words), checksum (2), and end-of-line (2). That is a total of 45 bytes per record line, representing 8 instruction words. For 8K bytes words of flash memory, that would be 1024 lines 
...

So, 1024 is simply 8k (words of flash) divided by 8 (words per line in the hex file)
which is how many lines in the hex file are required to represent 8k words of FLASH memory.
 




How you mentioned 8 instruction words?
 
please explain
#8
NKurzman
A Guy on the Net
  • Total Posts : 15347
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: offline
Re: HEX file size 2017/10/07 08:34:07 (permalink)
+1 (1)
The Hex FILE typically stores 16 bytes per line that is equal to 8 words in this case.
#9
Jump to:
© 2018 APG vNext Commercial Version 4.5