PIC32 UART Full Duplex https://github.com/ibexuk/C_Communications_UART_PIC32_Full_Duplex PIC32 UART Half Duplex https://github.com/ibexuk/C_Communications_UART_PIC32_Half_Duplex PIC32 DMX https://github.com/ibexuk/C_Communications_DMX_PIC32_RX
Category: ~C32 (old)
AtoD
Register Based Working Example Set up AtoD //—– SETUP AtoD —– AD1PCFG = 0xFFFC; //AN1:0 analog, reset digital AD1CHSbits.CH0SA = 0; //Channel 0 positive input is AN0 AD1CON1bits.SSRC = 7; //Internal counter ends sampling and starts conversion (auto-convert) AD1CON1bits.ASAM = 1; //Sampling begins when SAMP bit is set //The PIC32 can sample up to 1000ksps, […]
SPI – PIC32
SPI Master //—– SETUP SPI 1 —– //Used for: //Idle low, active high //Transmit on active to idle (falling edge) SpiChnOpen(SPI_CHANNEL1, (SPI_CON_MSTEN | SPI_OPEN_CKE_REV | SPI_CON_MODE8), 2); //40MHz fpb / 2 = 20MHz SPI Slave #define COMMS_SPI_NAME SPI_CHANNEL3 #define COMMS_SPI_ID SPI_CHANNEL3 #define COMMS_SPI_SS_PIN_STATE mPORTEReadBits(BIT_8) //—– SETUP SPI 3 —– //Used for: (we are slave with […]
Compiler Version
Viewing compiler version Project > Select Language Toolsuite
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 […]
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. […]
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) […]
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.
.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 […]