{"id":1380,"date":"2023-09-14T13:43:48","date_gmt":"2023-09-14T12:43:48","guid":{"rendered":"https:\/\/ibex.tech\/embedded\/?p=1380"},"modified":"2023-09-26T09:11:06","modified_gmt":"2023-09-26T08:11:06","slug":"io-pins-general-3","status":"publish","type":"post","link":"https:\/\/ibex.tech\/embedded\/microchip\/pic32\/xc32\/io-pins-xc32\/io-pins-general-3","title":{"rendered":".IO Pins General"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Inputs<\/h4>\n\n\n\n<h5 class=\"wp-block-heading\">Read pin<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>\tif (PORTBbits.RB0 == 0)\n\n#define IO_EXTERNAL_POWER_PRESENT\t\t(!PORTBbits.RB0)<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Read port<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>\tunsigned int MyVar = PORTB;<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Outputs<\/h4>\n\n\n\n<h5 class=\"wp-block-heading\">Write pin<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>\tLATAbits.LATA6 = 1;\n\tLATAbits.LATA7 = 0;\n\n#define\tLED\t\tLATEbits.LATE1\n\n#define CHARGE_OUTPUT(state)\t\tLATBbits.LATB0 = state<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Write port<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>\tLATA = 0x0040;\t\t\t\/\/Sets output latch. 0=low, 1=high\n\n\tLATASET = 0x0040;\t\t\/\/Sets high bits, without affecting other pins\n\n\tLATACLR = 0x0040;\t\t\/\/Clears high bits, without affecting other pins<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Direction<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>#define\tPORTA_IO\t0x0204\t\t\/\/Setup the IO pin type (0 = output, 1 = input)\n\n\tTRISA =  PORTA_IO;\n\n\tTRISASET = (PORTA_IO);\t\t\/\/Sets high bits as input, without affecting other pins\n\n\tTRISACLR = (~PORTA_IO);\t\t\/\/Sets high bits as output, without affecting other pins\n\n\n#define\tKEYPAD_POWER_TRIS(state)\t\tTRISEbits.TRISE2 = state<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Inputs Read pin Read port Outputs Write pin Write port Direction<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[108],"tags":[],"class_list":["post-1380","post","type-post","status-publish","format-standard","hentry","category-io-pins-xc32"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/1380","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=1380"}],"version-history":[{"count":7,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/1380\/revisions"}],"predecessor-version":[{"id":1476,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/1380\/revisions\/1476"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/media?parent=1380"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/categories?post=1380"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/tags?post=1380"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}