I'm trying to understand the procedure for getting some data from my PC onto a 25LC512 serial EEPROM chip using Pickit 2.
What I've got thus far: I found the pickit2/25LC pin connections hidden away in the Pickit 2 readme file. I've selected my device (25LC512) in Pickit 2 application.
Do I now simply need to import my data into Pickit 2 software as a hex file? If so, how do I get tabulated data from a text file (each datum is a single byte) into hex format?
hypothetical contents of my current .txt file.
7 4 6
2 9 2
6 8 8
...
Update: As soon as I submitted this post I realised I should check the reference section of the wikipedia article. Lo and behold, a ref to . I was able to get a series of bytes (the digits 1 to 8) to show up in the Pickit 2 'program memory' window.
Code:
:08001000010203040506070800
My question is now; do you have a recommended method for text to hex conversion, one that can turn my example column data into blocks of hex-formatted bytes?
I have done this with my junebug but it has been a while.
The easiest way to generat a HEX file is with the assembler. An ORG 0 statment to set the address followed by whatever data definitions you need. Most assembler have a few data directives like define_byte, define_word, and define string. Its easy the man said.
Inside the PICkit2 tool you have to do a few clicks to first select EEPROM>25LC and then select the specific device.
After that import the hext and program.
Thanks. I'll look into that. Perhaps also try and just make the hex file directly from the raw data. The data are actually signed floats so I'm sure I'm going to screw this up. Still, 30 minutes ago a hex file was a complete mystery, but now it doesn't seem so intimidating.
A while later ...
I threw a byte datatable written in assembly at MPASM
Code:
org 0
db 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08
db 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08
db 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08
end
Which makes sense, although I'm not entirely sure I know what the first and last lines are getting at. Progress, but it doesn't help me much as I still have to break up my datatypes into bytes - which is presumably what 3v0's 'define_byte, define_word, and define_string' comment referred to...
My question is now; do you have a recommended method for text to hex conversion, one that can turn my example column data into blocks of hex-formatted bytes?
The data are a series of x,y,z coordinates (each ideally a float) that I generated using IDL. In IDL I can write a text file very easily, with any formatting I desire. (In fact I just now see that there's a convenient function that turns an integer number into a Hex string.)
I'm learning C (but only in the context of 18F pics). How would you suggest I attack the problem, given that I can format the txt file however I please?
You may want to give C programming on the PC a try. Try using visual studio C++. It is possible to write pure C in that C++. It is a nice IDE. (Integrated Development Enviroment).
About the only tricky bits will be file handling and even that is not too bad. Execpt for that most of what you learn will be useful on the PIC18.
I normally do things like this in Excel using Visual Basic for Applications. I have routines to convert a decimal number into a 32 bit float. It would be relatively easy to modify them to do 64 bit if needed. It would also be fairly trivial to output a hex file from a list of floating points.
IDL is the Interactive Data Language, often used in astronomy and other sciences. Expensive license. Good for high level data manipulation; plots, images, data post-processing etc.
I use a Mac, my PC is barebones, bought it just for MPLAB. No MS Office. since I'm generating the data in IDL I think I should just try and write my blocks of hex there. I think it might be very easy. If I do anything in C I should probably use Mac's Xcode, as I've wanted to learn how to use that.
Thanks for the replies, I'll try and remember to post a progress report.
If your application is able to generate raw data, you could use 'bin2hex' to generate an Intel hex file from it. I have done this in the past so that I could dump data onto a serial eeprom using a PICKIT2. IIRC it can be downloaded readily and will run in a DOS window.
Then I added the control character '\x02' at the beginning and '\x03' at the end. The file is now in the 'Ascii Hex' format.
Next I downloaded and installed SRecord (SRecord 1.53) using MacPorts (The MacPorts Project -- Home) Once SRecord is installed I used it to convert the Ascii Hex file into Intel Hex using the command;