In this page I will describe the process of adapting the text files from the Silicon Labs ClockBuilder into macro assembly code that can run on a PIC12F629.
The function for this is under Options, "Save device registers (not for factory programming)".
The other programs used in this tutorial are the good old Windows Notepad for the "search & replace" function and Microsoft Excel (2002) as it can load .csv files.
The included data generates 49.65653Mhz (4.43361875Mhz * 4 * 14 / 5) on Channel 0.
This is a practical example used in my N64 as I broke off the output pin of the MX9911 clock generator while trying to lift it from the mainboard.
Start with Notepad first.
Delete all comments (lines that start with #, don't forget the last line at the bottom) then get rid of all "h" by replacing all those with nothing. Next to mass replace are all commas "," with ";0x".
Now save that as an .csv file.
Now load the .csv file into Excel.
Go to the last row and put "SendDatabyte" (a asm macro) into column A then drag that in a way to the top so that all previous numbers in column A get replaced with "SendDatabyte".
Now save the file.
Now load the changed .csv file back into Notepad.
Replace all semicolons ";" with an space " " and then you very likely need to add tabulators at the start of all lines or else MPASM will complain.
Doing that with Notepad is a bit tricky.
Add two tabulators before SendDatabyte manually and then copy-paste
that into the Replace with field, then do the same with the Find what field and delete the tabs in that one.
Now this will add two tabs on all lines.
Now save that as an .asm file.
Now open my CustomOSC.asm and change the #include in line 221 to your .asm file.
You can now assemble that with MPASM.
Additional information on the pinout are included in my CustomOSC.asm file and you can reduce the size by manually compressing the data by pasting "call i2c_send_wreg ;" before every with repeating bytes.
In my example it brought the size from 573 instructions down to 369.
With some extra code you could easily store two profiles and switch between them.
You could also port it to other PICs as well that have more program memory.
Download the ZIP here (source files with an assembled .hex file for testing purposes).
Return to the main index
--EOF--