Author Topic: Convert Excel output to chip programmer write buffer?  (Read 895 times)

0 Members and 1 Guest are viewing this topic.

Offline bklein

  • Contributor
  • Posts: 16
Convert Excel output to chip programmer write buffer?
« on: January 03, 2020, 05:27:51 am »
I am not a software guy so I was trying to use Excel....
My challenge is to program 200 EEPROMs - each with a unique MAC address.
So I need something to take the MAC address, put it in the right place along with the surrounding data, and create a checksum based upon the sum of all data, twos complement, plus 1 (or something like that).  Also the write buffer I saw had a checksum for each line in the buffer as well.
So I managed to create an Excel file that did this - after the MAC address is entered, the remaining checksums are created and the spreadsheet is laid out like the write buffer file should be (address, data, checksum each row).  I have correct column widths for the address, and data/checksum fields.
Now the challenge is to output to a binary file or whatever for the chip programmer to accept.  This is the gotcha. 
I don't find hex editors that take CSV files.
I feel like I'm missing something really simple but I ask around and no one has an idea except to start over and do it all in a programming language like C.

Offline SparkyFX

  • Frequent Contributor
  • **
  • Posts: 675
  • Country: de
Re: Convert Excel output to chip programmer write buffer?
« Reply #1 on: January 03, 2020, 06:59:35 am »
I created something like this in Excel. It writes binary data (based on the content of the spreadsheet) to a file, which then in turn gets included in a project that is written to some flash chip using the programmer. All is called from a VBA macro inside the document.

Press Alt+F11 to create a new VBA module in the file, go from cell to cell, convert the data, write it out to a file and this should do it.

The interesting parts of the code look like this:
Code: [Select]
filenum = FreeFile
If Dir(file) <> "" Then
    SetAttr file, vbNormal
    Kill (file)
End If

Open file For Binary Access Write As #filenum
Seek #filenum, 1
For a = LBound(data) To UBound(data)
    by = CByte(data(a))
    Put #filenum, a + 1, by
Next a

Close #filenum

where file is the filename with path, data an array containing the bytes.
« Last Edit: January 03, 2020, 07:15:51 am by SparkyFX »
Support your local planet.

Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo