0
\$\begingroup\$

I am trying to program my Microchip PIC24EP512GU814 in ICSP mode. The resource I'm using to do this is the Microchip dsPIC33E/PIC24E Flash programming Specifications (70619B) and the Microchip dsPIC33EP/PIC24EP Data Sheet (70616g). So far I've programmed an Arduino to enter ICSP mode, and erase everything on the chip, but I am currently stuck at writing on the chip.

Section 6.6 has a table 6-5 on page 31 which shows steps on how to write onto the chip. Step #6 has the following snippet:

MOV #DestinationAddress<15:0>, W2
MOV #DestinationAddress<23:16>, W3

In context: these instructions are to be executed once 128 instructions have been inputted into the write latches. This snippet define the location in the code memory into which the instructions from the write latches are copied.

I currently can't figure out which address I should start with, and how much does the address increment by for the next 128 instructions?

I've looked at the Section 4.1, Figure 4-1 of the Data Sheet (70616g) and Section 2.3, Figure 2-2 of the Programming Specifications (70619B). Is the code memory the same thing as the User Program Flash Memory in these figures? As such, should the destination address in the above snippet start at 0x000200?

Since this establishes a write for 128 instructions, does it increment by 128 = 0x80? Or does it increment by the number of bits written (24x128= 3072 = 0xC00)?

\$\endgroup\$
1
\$\begingroup\$

You'd start at 0x0, because the stuff there (IVT, etc) are part of what you want to upload. PIC addressing is always confusing because of their insistence on weird architectures with 14 or 24 bit words, but I believe the destination address would increment by 0x100 for 128 instructions -- this is supported by the comment in 5.2.9 of the programming spec, "The destination address should be a multiple of 0x100", as well as the flow chart shown in figure 3-4.

\$\endgroup\$
  • \$\begingroup\$ I didn't think about looking at the Enhanced ICSP instructions. Microchip should be more consistent with their documentation haha. Thanks for the answer! \$\endgroup\$ – Daniel Nov 6 '12 at 20:10
1
\$\begingroup\$

Your question comes down to basically how program memory is addressed. Yes, "flash" memory and "program" memory refer to mostly the same memory. Actually the program memory address space contains some other stuff, but it sounds like you are interested in the executable memory starting at 0.

All the dsPIC and derivative parts have 24 bit instruction words. However, program memory is addressed in words of 16 bits. Two addresses are used per instruction word. The first (even) address refers to the low 16 bits of each instruction, and the next (odd) refers to the upper 8 bits. The high 8 bits of that word are not implemented. A chunk of 128 instructions therefore uses 256 addresses and contains 384 bytes of actual memory.

\$\endgroup\$
  • \$\begingroup\$ Thanks for the answer. I did know how instructions were packed into the executable memory. \$\endgroup\$ – Daniel Nov 6 '12 at 20:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.