Difference between revisions of "PIC32"

From Steak Wiki
Jump to navigationJump to search
Line 2: Line 2:
 
==Tips==
 
==Tips==
 
===MX is not MZ===
 
===MX is not MZ===
Essentially there are two distinct PIC32 architectures. MX and MZ. The reference manuals (Family Reference Manuals) that apply to MZ do not apply to MX. A simple thing to misunderstand for beginners. Use the reference manual that is mentioned in your Pic's particular datasheet.
+
Essentially there are two distinct PIC32 architectures. MX and MZ (let's forget about MM). The reference manuals (Family Reference Manuals) that apply to MZ do not apply to MX. A simple thing to misunderstand for beginners. Use the reference manual that is mentioned in your Pic's particular datasheet.
 +
 
 
===Pic32 can be Power Hungry===
 
===Pic32 can be Power Hungry===
 
Check your voltage regulator if you find that your code keeps resetting, when in debug mode. I found that my resets were due to not enough power. The more peripherals you turn on, the more power you will need. This is one reason why code will work, then suddenly fail after adding functionality (say turning on DMA, or a constant UART stream)
 
Check your voltage regulator if you find that your code keeps resetting, when in debug mode. I found that my resets were due to not enough power. The more peripherals you turn on, the more power you will need. This is one reason why code will work, then suddenly fail after adding functionality (say turning on DMA, or a constant UART stream)

Revision as of 21:30, 25 October 2019

Some things I've learned about PIC32.

Tips

MX is not MZ

Essentially there are two distinct PIC32 architectures. MX and MZ (let's forget about MM). The reference manuals (Family Reference Manuals) that apply to MZ do not apply to MX. A simple thing to misunderstand for beginners. Use the reference manual that is mentioned in your Pic's particular datasheet.

Pic32 can be Power Hungry

Check your voltage regulator if you find that your code keeps resetting, when in debug mode. I found that my resets were due to not enough power. The more peripherals you turn on, the more power you will need. This is one reason why code will work, then suddenly fail after adding functionality (say turning on DMA, or a constant UART stream)

Read Registers Whilst Debugging

If you put just a register macro, e.g. U1STA; or U1MODE; in the code, and even if nothing happens to that register, it can be read by hovering over it while debugging. Useful to just type out a number of registers in the code, and then pause, and check them while debugging. An example:

U1MODE;
U1STA;
IFS1;
IEC1;
RCON;

Resets

Dest and Source Sizes

Incorrect Dest and Source sizes for DMA can cause resets. It will register as POR and BOR, but it's due to for example, the source of SPIxBUF being set to size 10 bytes, (which is incorrect, SPIxBUF can only be 1,2 or 4 bytes depending on settings).

Insufficient Power

Self explanatory.

Resources

Family Reference Manuals

Start here. These will be your required reading for any peripheral. The data sheets will also be required. With these two in hand, you should be able to flip almost any bit needed. Make sure you get the Reference manual for your particular implementation (MX or MZ).

Peripheral Library Examples

There are a number of well commented (unlike most garbage online) examples that are ideal for someone learning about setup of pic32 peripherals in the Peripheral Libraries Examples. Link: https://people.ece.cornell.edu/land/courses/ece4760/PIC32/PLIB_examples/plib_examples/