Coded and tested the trace offset calibration and ran into the problem that channel 2 came out OK, but channel 1 failed. Since it uses the special IC with parameter 0x12 to get some data I could not get it right on my simulator, so I wrote a bit of test code to write the results of the calls to the special IC to a file. It turns out it uses signed integers for the calculations, which was not clear from the Ghidra output.
Modified my code to also use signed integers and now it works like a charm, except for the same problem as the original. It is not consistent throughout the sensitivity settings.
I'm going to write a bit more test code to get a better insight into the special IC. With FatFS running it is now very simple to accomplish this.
I'm also updating both the scope projects (the original and the new code) with this, so it is still an option to finish the original reversal.
Still need to do the interleaving ADC compensation calibration and when that is done I will update the repository.
Attached the file with the output of the special IC data returned for parameter 0x12. Below is the code used to make it.
//Data read out special IC
if(f_open(&viewfp, "special_ic_data.txt", FA_CREATE_NEW | FA_WRITE) == FR_OK)
{
uint32 offset;
uint32 offset1;
uint32 offset2;
int8 valuestring[100];
int8 *ptr;
int8 headerstring[] = "low,high,result\n";
f_write(&viewfp, headerstring, sizeof(headerstring) - 1, 0);
for(offset1=200;offset1<=1500;offset1+=50)
{
for(offset2=1500;offset2>=200;offset2-=50)
{
offset = fpga_read_parameter_ic(0x12, (offset1 & 0x0000FFFF) | (offset2 << 16));
ptr = scope_print_decimal(valuestring, offset1, 0);
*ptr++ = ',';
ptr = scope_print_decimal(ptr, offset2, 0);
*ptr++ = ',';
ptr = scope_print_decimal(ptr, offset, 0);
*ptr++ = '\n';
f_write(&viewfp, valuestring, ptr - valuestring, 0);
}
}
//Close the file to finish the write
f_close(&viewfp);
//Show the saved successful message
scope_display_file_status_message(MESSAGE_SAVE_SUCCESSFUL, 1);
}