Peripheral Pin Select

To set or clear the IOLOCK bit, an unlock sequence must be executed: #define PPSUnLock() {SYSKEY=0x0; SYSKEY=0xAA996655; SYSKEY=0x556699AA; CFGCONbits.IOLOCK=0;} #define PPSLock() {SYSKEY=0x0; SYSKEY=0xAA996655; SYSKEY=0x556699AA; CFGCONbits.IOLOCK=1;} Note these defines are likely already included in xc32 UART DISABLE_INT; PPSUnLock() //PPS Unlock (required before setting peripheral pin, if config bit IOL1WAY is set only 1 change of IOLOCK […]

Read More

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 //}      

Read More

.IO Pins General

  Read Port my_var = mPORTBRead(); Read pin if (mPORTBReadBits(BIT_10)) switches_1_read |= 0x0001; #define EXTERNAL_POWER_PRESENT (!mPORTDReadBits(BIT_11)) Write Pin #define READY_LED_ON(state) (state ? mPORTCClearBits(BIT_14) : mPORTCSetBits(BIT_14)) Write Port mPORTEWrite(0x5555) mPORTESetBits(0x00ff); mPORTEClearBits(0xff00); Set Pin TRIS #define ENABLE_MEASUREMENT(state) (state ? mPORTESetPinsDigitalOut(BIT_5) : mPORTESetPinsDigitalIn(BIT_5))  

Read More