[sdiy] First exchanges with ChatGPT... program code extract + conversion.. AWESOME !!!

jpdesroc at oricom.ca jpdesroc at oricom.ca
Mon May 4 15:49:59 CEST 2026


In 1996 I designed a 2 octaves MIDI Bass pedal board

made around what I used at that time.. a Motorola HC811E2 micro.







The circuit included a complete synth structure with ADSR, 2 VCO’s VCA, VCF
and MIDI output.

It still works very well after all those years.

But recently I tried to browse my original program listings and HEX files (.
S19 file for Motorola)

to see what I’d done in the past… but.. no such files left !! Woohh..

Only some hand written schematics and notes on papers.

BUT I also had a pile of 26 pages of the original .LST file which was the
printed results
of the original compiled assembler code that was lost over time..

The assembler compiler I used was IASM11.

Pages like this:







That is what I only had left from my original design..

My goal now was to ‘retrieve’ my .S19 compiled code from the installed
HC811E2

and save it in case something goes wrong with the micro so I could reprogram
another one. But I did not have the appropriate hardware to read the HC..

So I thought.. Why not redo this design with the same schematic
but using a new PIC micro instead ?

After checking the needed amount of I/O pins I found the PIC16F1789
could be a good replacement..



Since the only thing left of my code were the 26 printed pages
I needed to extract the actual text code from these and save
them in 26 separate .TXT files.

I first scanned all the 26 pages and saved them in JPG format.

Then I browsed the web to find any ‘On Line OCR’ available

and found some.. But the OCR extractions were not good at all
missing or misreading many characters.. !!

So I thought ChatGPT could be a solution in my case..
My first try with this tool.

I went to ChatGPT and asked it to OCR my first JPG code page
which it did very efficiently !



Ok.. I did the same with all the 26 pages.

26 text files saved.

I then ‘merged’ in order all these pages in one single page of assembler
code.



So far ChatGPT had been a good partner for my job..



Next step:

I asked ChatGPT to read my  HC811E2 assembler code file and
create a Microchip XC8 C code for PIC16F1789
giving it a clear description of the original HC11 pins number/function
and the new PIC pins number/function to achieve the same job.



Its reply:

The source code is very large (more than 1000 lines with the complete
POT_VAL table),

so to make a clean, reliable and compilable conversion to XC8 for
PIC16F1789, you must proceed in structured phases.



This is the correct method - otherwise you get incorrect or unusable code.

I will therefore continue exactly as in your previous requests, by
generating:



Phase 1

PIC16F1789 Full Hardware Configuration:



CONFIG bits

Internal oscillator 32 MHz + PLL

ADC RA0-RA3

USART MIDI 31250 baud on RC6

PORTB outputs

PORTD entries

RC0-RC5 outputs

Timer1

CCP1 / CCP2 replacement TOC2 / TOC3

global variables HC11 → C



Phase 2

Conversion of structures:



note tables (DO1 → DO3)

NOTE/PERIOD structure

table POT_VAL[256]

10-bit ADC reading → conservation of 8 MSB

automatic table lookup



Phase 3

Conversion of routines:



NOON()

TXMIT()

ADC()

JAR()

ADSR()

SAW()

DEBOUNC()

DEADLINE()



Phase 4

Main logic conversion:



CHANNEL()

TEST()

main loop

NOTE ON / NOTE OFF management

scanning complete crankset

final CCP1/CCP2 interrupts



I then refined my request giving it back its code

and asking it to merge all these 4 phases together
in one single .C program.



I did not include here the final code listed by ChatGPT..

I then checked it carefully for all the Ins, OUTs, interrupts, clock speed,
TIMERs, etc..

Loaded it in MPLAB X compiler and.. IT WORKED !!!!

I couldn’t believe it..

All this result starting from scanned listing pages !!



That’s all I wanted to share with you..

For my needs here.. No special AI software to buy..

I’m very happy !



And,, sorry for this long email but.. Yeah !


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://synth-diy.org/pipermail/synth-diy/attachments/20260504/25b2357e/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.jpg
Type: image/jpeg
Size: 22921 bytes
Desc: not available
URL: <http://synth-diy.org/pipermail/synth-diy/attachments/20260504/25b2357e/attachment.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image005.png
Type: image/png
Size: 346994 bytes
Desc: not available
URL: <http://synth-diy.org/pipermail/synth-diy/attachments/20260504/25b2357e/attachment.png>


More information about the Synth-diy mailing list