2011-05-17, 05:31:00
I FIXED IT.
I found I had to do three things to make dsloader work in my project.
1. I had to put a 100ms delay AFTER initialization of the UART. Putting this at the beginning of the code did not help.
2. Right after the 100 ms delay, I had to read the uart input continuously until it was clear.
3. On both processors the pins I was using for the RX pins were also analog pins, so I had to set the appropriate bits in AD1PCFGL on both processors to switch them to digital.
After I found item 3, I tried removing the delay and the clearing of the uart. Unless I did all three items ds30loader did not work!
Interestingly enough I had to also do items 1 & 2 in my C code to get my application programs to run when directly loaded. Otherwise they would hang up when the uart was turned on in the code. I'm sure the c compiler took care of item 3, so my c programs worked fine.
Why the delay?? I don't know. I did not try a shorter delay. I did not need the delay when using an 8 MHz crystal and PLL, but I do need it now with a 32 MHz crystal and no PLL.
Why do I have to clear the uart receive register multiple times? I don't know. Again I did not have to do that on the test board.
I found I had to do three things to make dsloader work in my project.
1. I had to put a 100ms delay AFTER initialization of the UART. Putting this at the beginning of the code did not help.
2. Right after the 100 ms delay, I had to read the uart input continuously until it was clear.
3. On both processors the pins I was using for the RX pins were also analog pins, so I had to set the appropriate bits in AD1PCFGL on both processors to switch them to digital.
After I found item 3, I tried removing the delay and the clearing of the uart. Unless I did all three items ds30loader did not work!
Interestingly enough I had to also do items 1 & 2 in my C code to get my application programs to run when directly loaded. Otherwise they would hang up when the uart was turned on in the code. I'm sure the c compiler took care of item 3, so my c programs worked fine.
Why the delay?? I don't know. I did not try a shorter delay. I did not need the delay when using an 8 MHz crystal and PLL, but I do need it now with a 32 MHz crystal and no PLL.
Why do I have to clear the uart receive register multiple times? I don't know. Again I did not have to do that on the test board.