Reset

Reset //Reset to 0x0000: SoftReset(); Did Watchdog reset occur if (ReadEventWDT()) //WDT reset has occurred Generating Reset in Code If you want to use your own code as an alternative to the C32 SoftReset function the following can be used instead: void software_reset(void) { int t; //Unlock system SYSKEY=0; SYSKEY=0xaa996655; SYSKEY=0x556699aa; //Do the reset RSWRSTSET=1; //enable […]

Read More

PIC32 Pin Notes

USB D+ & D- pins – INPUT ONLY!!! On PIC32MX695F512L the D- and D+ pins can only be used as inputs when USB bus disabled. USB ID pin On PIC32MX695F512L the USBID pin can used as GPIO (we have used as output) when USB bus disabled. UART TX On PIC32MX695F512L the U2TX can used as […]

Read More

Oscillator Configuration

Typical fastest setup (80MHz with 1x divide, 20x multiply, 2 x divide) Using an 8MHz crystal #pragma config FPLLIDIV = DIV_2 //PLL Input Divider (Must produce 4-5MHz from crystal frequency) #pragma config FPLLODIV = DIV_1 //PLL Output Divider #pragma config FPLLMUL = MUL_20 //PLL Multiplier //SYSTEMConfigPerformance(80000000ul); //Note this sets peripheral bus to '1' max speed (regardless […]

Read More

Memory

  PIC32 stores 32bit words with address incrementing by 4 for each instruction PIC32's implement two address schemes: virtual and physical. All hardware resources (program memory, data memory and peripherals) are located at their respective physical addresses. Virtual addresses are exclusively used by the CPU to fetch and execute instructions as well as access peripherals. […]

Read More

Linker scripts

procdefs.ld is the file you typically modify. Method 1 – Copy In Both Linker Scripts & Modify Copy the file “elf32pic32mx.x” from to your project directory from “C:\Program Files\Microchip\MPLAB C32\pic32mx\lib\ldscripts\” Rename it “elf32pic32mx.ld” Add it to your project (must be added prior to the next linker script so it is treated as the main script) […]

Read More

IRQ’s

Bootloader “Bootstrap” Mode IRQ’s are disabled 0xbfc00380 is automatically set as the exception irq vector address. Single Vector IRQ Mode IRQ vector address is set by the EBase register Single Vector IRQ Mode Each IRQ vector address is set by the EBase register and the VS bits in the IntCtl register.

Read More

.C32 Compiler General

Documentation MPLAB help menu has old pdf's in the C32 compiler section – don't use! In the general section there is the proper help file links which is the current documentation File locations You may have two MPLAB C32 directories: C:\Program Files (x86)\Microchip\MPLAB C32 Suite\ The compiler that is installed from MPLAB IDE's installer. C:\Program Files […]

Read More

SPI

//—– SETUP SPI 1 —– //Used for: Flash memory IC w_temp = SPI1BUF; SPI1STAT = 0; SPI1CON1 = 0x0320; //SPI in master mode //Data is valid on the rising edge of the clock (Transmit occurs on transition from active to idle clock state) //Clock low in idle bus state SPI1CON1bits.PPRE1 = 1; //Prescallers 4:1 1:1 […]

Read More

Reset Function

Soft Reset asm("reset"); Reset Function Generally the C30 will use the startup module to do some setup works. Refer to the device linker script file (p24HJ256GP206.gld), there are something like: OUTPUT_ARCH("24HJ256GP206") CRT0_STARTUP(crt0_standard.o) CRT1_STARTUP(crt1_standard.o) OPTIONAL(-lp24HJ256GP206) The CRTn_STARTUP commands specify two C run-time startup modules to be loaded from archives. The linker will select one of these […]

Read More

Peripheral Libraries

Peripheral Library Documentation You need to go to the library files themselves for the documentation – its not in MPLAB help: C:\Program Files (x86)\microchip\MPLAB C30\docs\periph_lib\

Read More