U1RXREG has incorrect values, but code works fine when someone else programs the pic
So, I got some code (12ch_control.txt
) which, after asking multiple times, I was assured works, and is the version the person used when programing the dsPIC30F himself. I've tested the code, and the device responds to the data properly.
However, when I try to program the device with the same code, while debugging, the RX interrupt is raised, but the content of U1RXREG is incorrect - either always 0 or 0x42 (it switched from 0 to 0x42 and back to 0 again between debug sessions, not sure why).
I have used MPLAB X IDE v5.35 with a PICkit 3 and XC16, as well as MPLAB v8.92 with PICkit 2 and both XC16 and MC30 to no avail.
I'm very new to PIC programing but I can't imagine how this could be possible, that it works for one person (also using some version of MPLAB v8 and a PICkit 2) and not the other. I'm stumped.
Also attached is the Python script I used to send data to the PIC. Every byte I send causes the IDE to halt at the breakpoint I set (where the value of U1RXREG is assigned to the variable) and as I've said, the content is just wrong.
Also, note that there's a bug - the array size allocated for received data is too small, and read/write operations are performed beyond the boundary. I tried fixing it when I used MPLAB X but it didn't solve any problems, though come to think of it, I didn't do "Clean and build" (just "Make and program device"), but again - I was assured that this is indeed the code he used which actually works when he programs the device... so I'm using the code I was sent as is
because I don't want to risk adding a new problem when I still have this one to solve...
Any help would be very much appreciated!