{"id":133,"date":"2012-05-24T09:02:27","date_gmt":"2012-05-24T09:02:27","guid":{"rendered":"http:\/\/www.electronic-products-development.com\/?p=133"},"modified":"2023-09-15T09:10:12","modified_gmt":"2023-09-15T08:10:12","slug":"defines-2","status":"publish","type":"post","link":"https:\/\/ibex.tech\/embedded\/microchip\/mplab-x\/defines-2","title":{"rendered":"Defines"},"content":{"rendered":"<h4>\nMicrochip define examples<\/h4>\n<pre>\n<code>\n#ifdef __DEBUG                      \/\/Debug mode selected in MPLAB\n#if defined(__18CXX)\n#elif defined(__C30__)\n#elif defined (__PIC32MX__)\n#else\n#endif\n\n\n#ifndef __DEBUG\n\n#if (defined(__18CXX) &amp; !defined(PIC18F87J50_PIM))\n#endif\n\n#if defined(PIC18F87J50_PIM) || defined(PIC18F46J50_PIM)\n#if defined(__PIC24FJ256GB110__)\n\n#if defined(__18F46J50)\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<h4>\nIs This&nbsp;Microcontoller In Use<\/h4>\n<pre>\n<code>\n#if defined( __PIC24FJ256GB106__ )\n\n#if defined(__PIC24FJ256GB110__) || defined(__PIC24FJ256GB106__) || defined(__PIC24FJ256GA110__) || defined(__PIC24FJ256GB210__)\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<h4>\nHandy&nbsp;UART&nbsp;Setup Example<\/h4>\n<pre>\n<code>\n\t#define USART1_BAUDRATE                         19200\n\t#define USART1_BRG                              (((GetSystemClock()\/2)+(USART1_BRG_DIV\/2*USART1_BAUDRATE))\/USART1_BRG_DIV\/USART1_BAUDRATE-1)\n\t#define BAUD1_ACTUAL                            ((GetSystemClock()\/2)\/USART1_BRG_DIV\/(USART1_BRG+1))\n\n\t#define BAUD1_ERROR                             ((BAUD1_ACTUAL &gt; USART1_BAUDRATE) ? BAUD1_ACTUAL-USART1_BAUDRATE : USART1_BAUDRATE-BAUD1_ACTUAL)\n\t#define BAUD1_ERROR_PERCENT_HUNDREDS            ((BAUD1_ERROR*10000+USART1_BAUDRATE\/2)\/USART1_BAUDRATE)\n\n\t#if (BAUD1_ERROR_PERCENT_HUNDREDS &gt; 200)\n\t\t#error UART frequency error is worse than 2%\n\t#endif\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Microchip define examples #ifdef __DEBUG \/\/Debug mode selected in MPLAB #if defined(__18CXX) #elif defined(__C30__) #elif defined (__PIC32MX__) #else #endif #ifndef __DEBUG #if (defined(__18CXX) &amp; !defined(PIC18F87J50_PIM)) #endif #if defined(PIC18F87J50_PIM) || defined(PIC18F46J50_PIM) #if defined(__PIC24FJ256GB110__) #if defined(__18F46J50) &nbsp; Is This&nbsp;Microcontoller In Use #if defined( __PIC24FJ256GB106__ ) #if defined(__PIC24FJ256GB110__) || defined(__PIC24FJ256GB106__) || defined(__PIC24FJ256GA110__) || defined(__PIC24FJ256GB210__) &nbsp; Handy&nbsp;UART&nbsp;Setup Example #define [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25,23],"tags":[],"class_list":["post-133","post","type-post","status-publish","format-standard","hentry","category-mplab","category-mplab-x"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/133","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=133"}],"version-history":[{"count":7,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/133\/revisions"}],"predecessor-version":[{"id":1421,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/133\/revisions\/1421"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/media?parent=133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/categories?post=133"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/tags?post=133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}