Inputs #define INPUT_1 PORTBbits.RB11 #define INPUT_2 _RB11 Outputs #define OUTPUT_1(state) LATBbits.LATB10 = state #define OUTPUT_2(state) _LATB10 = state #define OUTPUT_3(state) (state ? (_LATB10 = 1) : (_LATB10 = 0)) Peripheral Pin Select dsPIC33EP256MU806 example: //—– SETUP PERIPHERAL PIN SELECT —– RPINR14bits.QEA1R = 66; //QEI1 Phase A on RP66 RPINR14bits.QEB1R = 67; //QEI1 Phase B on […]
All posts by
Configuration Bits
You can get the config field defines from the C:\Program Files (x86)\Microchip\mplabc18\v#.##\mpasm\ .inc file for your PIC18 device
Math functions not available
2014-03 – Functions like round() and nearbyint() are in the xc32 mplab help but don't appear to actually exist when compiling? From support: Functions round() and nearbyint() are from Dinkumware C++ libraries packaged along with C++ compiler. The Dinkum Complete Libraries are a collection of several C++ libraries, all based on ISO standards. You can […]
INT Pins
Detecting An Int Pin Edge Has Occured //—– SETUP INT 4 PIN —– ConfigINT4(EXT_INT_PRI_1 | FALLING_EDGE_INT | EXT_INT_DISABLE); //Priority, edge trigger, enable. This also clear the irq flat //if (mINT4GetIntFlag()) //{ // mINT4ClearIntFlag(); //Reset the flag //}
Linker Scripts General
Default linker scripts are stored in: XC32 Compiler: "C:\Program Files (x86)\Microchip\xc32\v1.10\pic32-libs\proc\" To use a customised version simply copy it into your projects folder. Do NOT add it to your project in MPLAB X, only copy it into the project directory (if you add it you also have to add the primary elf32pic32mx.* but by not […]
Delays
uS Delay Function Using Core Timer mS Delay Function Using Core Timer
.MPLAB X Things to know
Watches Window There’s a button on the right of it that allows different column types to be shown so you can see multiple data types at once. If you’ve got a colum selected as the sort order it won’t allow you to drag the order of variables around. If you change the type of a […]
UART
PIC24 UART Full Duplex https://github.com/ibexuk/C_Communications_UART_PIC24_Full_Duplex
UART
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
.IO Pins General
Read Port Read pin Write Pin Write Port Set Pin TRIS