{"id":669,"date":"2015-12-18T09:38:31","date_gmt":"2015-12-18T09:38:31","guid":{"rendered":"https:\/\/ibex.tech\/embedded\/?p=669"},"modified":"2022-02-18T15:37:48","modified_gmt":"2022-02-18T15:37:48","slug":"peripheral-pin-select-2","status":"publish","type":"post","link":"https:\/\/ibex.tech\/embedded\/microchip\/pic32\/xc32-v2-old\/io-pins\/peripheral-pin-select-2","title":{"rendered":"Peripheral Pin Select"},"content":{"rendered":"<p>\nTo set or clear the IOLOCK bit, an unlock sequence must be executed:\n<\/p>\n<pre>\r\n<code>\r\n#define PPSUnLock() {SYSKEY=0x0; SYSKEY=0xAA996655; SYSKEY=0x556699AA; CFGCONbits.IOLOCK=0;}\r\n#define PPSLock() {SYSKEY=0x0; SYSKEY=0xAA996655; SYSKEY=0x556699AA; CFGCONbits.IOLOCK=1;}\r\n<\/code><\/pre>\n<p>\n<em>Note these defines are likely already included in xc32<\/em>\n<\/p>\n<h5>\nUART<br \/>\n<\/h5>\n<pre>\r\n<code>\r\n\tDISABLE_INT;\r\n\tPPSUnLock()\t\t\t\t\/\/PPS Unlock (required before setting peripheral pin, if config bit IOL1WAY is set only 1 change of IOLOCK is permitted)\r\n\t\/\/Input\r\n\tU1RXRbits.U1RXR = 0x04;\t\t\/\/RPB2\r\n\t\/\/Output\r\n\tCFGCONbits.IOLOCK = 0;\r\n\tRPB3Rbits.RPB3R = 0x01;\t\t\/\/U1TX\r\n\tPPSLock();\t\t\t\t\/\/PPS Lock\r\n\tENABLE_INT;\t\t\/\/&lt;&lt;&lt;if irqs have been set!\r\n<\/code><\/pre>\n<h5>\nSPI<br \/>\n<\/h5>\n<pre>\r\n<code>\r\n\t\/\/----- SPI2 -----\r\n\tDISABLE_INT;\r\n\tPPSUnLock()\t\t\t\t\/\/PPS Unlock (required before setting peripheral pin, if config bit IOL1WAY is set only 1 change of IOLOCK is permitted)\r\n\t\/\/Input\r\n\tSDI2Rbits.SDI2R = 0x03;\t\t\/\/RPD11\r\n\t\/\/Output\r\n\tRPB3Rbits.RPB3R = 0x06;\t\t\/\/SDO2\r\n\tPPSLock();\t\t\t\t\/\/PPS Lock\r\n\tENABLE_INT;\t\t\/\/&lt;&lt;&lt;if irqs have been set!\r\n<\/code><\/pre>\n<p>\n&nbsp;\n<\/p>\n<p>\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[45],"tags":[],"class_list":["post-669","post","type-post","status-publish","format-standard","hentry","category-io-pins"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/669","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/comments?post=669"}],"version-history":[{"count":9,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/669\/revisions"}],"predecessor-version":[{"id":842,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/669\/revisions\/842"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/media?parent=669"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/categories?post=669"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/tags?post=669"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}