<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=iso-2022-jp"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:12.0pt;
font-family:"Calibri",sans-serif;
mso-ligatures:standardcontextual;
mso-fareast-language:EN-US;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=FR-CA link="#0563C1" vlink="#954F72" style='word-wrap:break-word'><div class=WordSection1><p class=MsoNormal><span lang=EN-CA>In 1996 I designed a 2 octaves MIDI Bass pedal board<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA>made around what I used at that time.. </span>a Motorola HC811E2 micro.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><img width=621 height=348 style='width:6.4687in;height:3.625in' id="_x0000_i1026" src="cid:image002.jpg@01DCDBAB.5F025070"><o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span lang=EN-CA>The circuit included a complete synth structure with ADSR, 2 VCO$B!G(Bs VCA, VCF and MIDI output.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA>It still works very well after all those years.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA>But recently I tried to browse my original program listings and HEX files (.S19 file for Motorola)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA>to see what I$B!G(Bd done in the past$B!D(B but.. no such files left !! Woohh.. <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA>Only some hand written schematics and notes on papers.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA>BUT I also had a pile of 26 pages of the original .LST file which was the printed results<br>of the original compiled assembler code that was lost over time..<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA>The assembler compiler I used was IASM11.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA>Pages like this:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-CA><img width=609 height=465 style='width:6.3437in;height:4.8437in' id="Image_x0020_1" src="cid:image005.png@01DCDBAB.5F025070"></span><span lang=EN-CA><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-CA>That is what I only had left from my original design..<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA>My goal now was to $B!F(Bretrieve$B!G(B my .S19 compiled code from the installed HC811E2<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA>and save it in case something goes wrong with the micro so I could reprogram<br>another one. But I did not have the appropriate hardware to read the HC..<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA>So I thought.. Why not redo this design with the same schematic<br>but using a new PIC micro instead ?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA>After checking the needed amount of I/O pins I found the PIC16F1789<br>could be a good replacement..<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-CA>Since the only thing left of my code were the 26 printed pages<br>I needed to extract the actual text code from these and save<br>them in 26 separate .TXT files.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA>I first scanned all the 26 pages and saved them in JPG format.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA>Then I browsed the web to find any $B!F(BOn Line OCR$B!G(B available<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA>and found some.. But the OCR extractions were not good at all<br>missing or misreading many characters.. !!<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA>So I thought ChatGPT could be a solution in my case..<br>My first try with this tool.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA>I went to ChatGPT and asked it to OCR my first JPG code page<br>which it did very efficiently !<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-CA>Ok.. I did the same with all the 26 pages. <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA>26 text files saved.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA>I then $B!F(Bmerged$B!G(B in order all these pages in one single page of assembler code.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-CA>So far ChatGPT had been a good partner for my job..<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-CA>Next step:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA>I asked ChatGPT to read my HC811E2 assembler code file and<br>create a Microchip XC8 C code for PIC16F1789<br>giving it a clear description of the original HC11 pins number/function<br>and the new PIC pins number/function to achieve the same job.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-CA>Its reply:<o:p></o:p></span></p><p class=MsoNormal><i><span lang=EN style='color:#7030A0'>The source code is very large (more than 1000 lines with the complete POT_VAL table), <o:p></o:p></span></i></p><p class=MsoNormal><i><span lang=EN style='color:#7030A0'>so to make a clean, reliable and compilable conversion to XC8 for PIC16F1789, you must proceed in structured phases.<o:p></o:p></span></i></p><p class=MsoNormal><i><span lang=EN style='color:#7030A0'><o:p> </o:p></span></i></p><p class=MsoNormal><i><span lang=EN style='color:#7030A0'>This is the correct method — otherwise you get incorrect or unusable code.<o:p></o:p></span></i></p><p class=MsoNormal><i><span lang=EN style='color:#7030A0'>I will therefore continue exactly as in your previous requests, by generating:</span></i><i><span lang=EN-CA style='color:#7030A0'><o:p></o:p></span></i></p><p class=MsoNormal><i><span lang=EN-CA style='color:#7030A0'><o:p> </o:p></span></i></p><p class=MsoNormal><b><i><span lang=EN style='font-size:18.0pt;color:#7030A0'>Phase 1<o:p></o:p></span></i></b></p><p class=MsoNormal><i><span lang=EN style='color:#7030A0'>PIC16F1789 Full Hardware Configuration:<o:p></o:p></span></i></p><p class=MsoNormal><i><span lang=EN style='color:#7030A0'><o:p> </o:p></span></i></p><p class=MsoNormal><b><i><span lang=EN style='color:#7030A0'>CONFIG bits<o:p></o:p></span></i></b></p><p class=MsoNormal><i><span lang=EN style='color:#7030A0'>Internal oscillator 32 MHz + PLL<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7030A0'>ADC RA0–RA3<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7030A0'>USART MIDI 31250 baud on RC6<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7030A0'>PORTB outputs<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7030A0'>PORTD entries<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7030A0'>RC0–RC5 outputs<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7030A0'>Timer1<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7030A0'>CCP1 / CCP2 replacement TOC2 / TOC3<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7030A0'>global variables HC11 $B"*(B C<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7030A0'><o:p> </o:p></span></i></p><p class=MsoNormal><b><i><span lang=EN style='font-size:18.0pt;color:#7030A0'>Phase 2<o:p></o:p></span></i></b></p><p class=MsoNormal><i><span style='color:#7030A0'>Conversion of structures:<o:p></o:p></span></i></p><p class=MsoNormal><i><span style='color:#7030A0'><o:p> </o:p></span></i></p><p class=MsoNormal><i><span lang=EN style='color:#7030A0'>note tables (DO1 $B"*(B DO3)<o:p></o:p></span></i></p><p class=MsoNormal><i><span lang=EN style='color:#7030A0'>NOTE/PERIOD structure<o:p></o:p></span></i></p><p class=MsoNormal><i><span lang=EN style='color:#7030A0'>table POT_VAL[256]<o:p></o:p></span></i></p><p class=MsoNormal><i><span lang=EN style='color:#7030A0'>10-bit ADC reading $B"*(B conservation of 8 MSB<o:p></o:p></span></i></p><p class=MsoNormal><i><span lang=EN style='color:#7030A0'>automatic table lookup<o:p></o:p></span></i></p><p class=MsoNormal><i><span lang=EN style='color:#7030A0'><o:p> </o:p></span></i></p><p class=MsoNormal><b><i><span lang=EN style='font-size:18.0pt;color:#7030A0'>Phase 3<o:p></o:p></span></i></b></p><p class=MsoNormal><i><span lang=EN style='color:#7030A0'>Conversion of routines:<o:p></o:p></span></i></p><p class=MsoNormal><i><span lang=EN style='color:#7030A0'><o:p> </o:p></span></i></p><p class=MsoNormal><i><span lang=EN style='color:#7030A0'>NOON()<o:p></o:p></span></i></p><p class=MsoNormal><i><span lang=EN style='color:#7030A0'>TXMIT()<o:p></o:p></span></i></p><p class=MsoNormal><i><span lang=EN style='color:#7030A0'>ADC()<o:p></o:p></span></i></p><p class=MsoNormal><i><span lang=EN style='color:#7030A0'>JAR()<o:p></o:p></span></i></p><p class=MsoNormal><i><span lang=EN style='color:#7030A0'>ADSR()<o:p></o:p></span></i></p><p class=MsoNormal><i><span lang=EN style='color:#7030A0'>SAW()<o:p></o:p></span></i></p><p class=MsoNormal><i><span lang=EN style='color:#7030A0'>DEBOUNC()<o:p></o:p></span></i></p><p class=MsoNormal><i><span lang=EN style='color:#7030A0'>DEADLINE()<o:p></o:p></span></i></p><p class=MsoNormal><i><span lang=EN style='color:#7030A0'><o:p> </o:p></span></i></p><p class=MsoNormal><b><i><span lang=EN style='font-size:18.0pt;color:#7030A0'>Phase 4<o:p></o:p></span></i></b></p><p class=MsoNormal><i><span lang=EN style='color:#7030A0'>Main logic conversion:<o:p></o:p></span></i></p><p class=MsoNormal><i><span lang=EN style='color:#7030A0'><o:p> </o:p></span></i></p><p class=MsoNormal><i><span lang=EN style='color:#7030A0'>CHANNEL()<o:p></o:p></span></i></p><p class=MsoNormal><i><span lang=EN style='color:#7030A0'>TEST()<o:p></o:p></span></i></p><p class=MsoNormal><i><span lang=EN style='color:#7030A0'>main loop<o:p></o:p></span></i></p><p class=MsoNormal><i><span lang=EN style='color:#7030A0'>NOTE ON / NOTE OFF management<o:p></o:p></span></i></p><p class=MsoNormal><i><span lang=EN style='color:#7030A0'>scanning complete crankset<o:p></o:p></span></i></p><p class=MsoNormal><i><span lang=EN style='color:#7030A0'>final CCP1/CCP2 interrupts</span></i><i><span lang=EN-CA style='color:#7030A0'><o:p></o:p></span></i></p><p class=MsoNormal><span lang=EN-CA><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-CA>I then refined my request giving it back its code<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA>and asking it to merge all these 4 phases together<br>in one single .C program.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-CA>I did not include here the final code listed by ChatGPT..<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA>I then checked it carefully for all the Ins, OUTs, interrupts, clock speed, TIMERs, etc..<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA>Loaded it in MPLAB X compiler and.. IT WORKED !!!!<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA>I couldn$B!G(Bt believe it.. <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA>All this result starting from scanned listing pages !!<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-CA>That$B!G(Bs all I wanted to share with you..<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA>For my needs here.. No special AI software to buy..<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA>I$B!G(Bm very happy !<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-CA>And,, sorry for this long email but.. Yeah !<br> <o:p></o:p></span></p></div></body></html>