For using the programmer (pp3.c) under Windows some minor changes:
1. Uncomment (or better replace) delay functions in sleet_ms()
2. Retrying ReadFile() if 0 bytes are read:
int getByte()
{
int ntotal=0;
unsigned char buf[2];
int n;
do
{
ReadFile(port_handle, buf, 1, (LPDWORD)((void *)&n), NULL);
ntotal++;
} while(n==0 && ntotal<50);
if (verbose>3)
flsprintf(stdout,n<1?"RX: fail\n":"RX: 0x%02X\n", buf[0] & 0xFF);
if (n == 1)
return buf[0] & 0xFF;
comErr("Serial port failed to receive a byte, read returned %d\n", n);
return -1; // never reached
}
3. Changes in InitSerialPort():#if defined(__linux__)
strcpy(portname,"\\\\.\\");
#else
strcpy(portname,"");
#endif
Compiling with: gcc pp3.c -o pp3.exe
And here changes for PIC18f4622 CPU:
else if (strcmp("18f46k22",cpu)==0)
{
flash_size = 32768;
page_size = 64;
devid_expected = 0x5400;
devid_mask = 0xFFE0;
chip_family = CF_P18F_A;
}
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.
Yes, programming worked for me.
Are you sure? yes | no
@webwicht did you actually try programming the PIC18F46K22?
Are you sure? yes | no