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) & !defined(PIC18F87J50_PIM))
#endif

#if defined(PIC18F87J50_PIM) || defined(PIC18F46J50_PIM)
#if defined(__PIC24FJ256GB110__)

#if defined(__18F46J50)

 

Is This Microcontoller In Use


#if defined( __PIC24FJ256GB106__ )

#if defined(__PIC24FJ256GB110__) || defined(__PIC24FJ256GB106__) || defined(__PIC24FJ256GA110__) || defined(__PIC24FJ256GB210__)

 

Handy UART Setup Example


	#define USART1_BAUDRATE                         19200
	#define USART1_BRG                              (((GetSystemClock()/2)+(USART1_BRG_DIV/2*USART1_BAUDRATE))/USART1_BRG_DIV/USART1_BAUDRATE-1)
	#define BAUD1_ACTUAL                            ((GetSystemClock()/2)/USART1_BRG_DIV/(USART1_BRG+1))

	#define BAUD1_ERROR                             ((BAUD1_ACTUAL > USART1_BAUDRATE) ? BAUD1_ACTUAL-USART1_BAUDRATE : USART1_BAUDRATE-BAUD1_ACTUAL)
	#define BAUD1_ERROR_PERCENT_HUNDREDS            ((BAUD1_ERROR*10000+USART1_BAUDRATE/2)/USART1_BAUDRATE)

	#if (BAUD1_ERROR_PERCENT_HUNDREDS > 200)
		#error UART frequency error is worse than 2%
	#endif

 

USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.

Comments

Your email address will not be published. Required fields are marked *