Click here to Skip to main content
15,895,011 members
Articles / Desktop Programming / MFC

A PIC C Code Wizard

Rate me:
Please Sign up or sign in to vote.
4.94/5 (27 votes)
5 May 2003CPOL5 min read 156.2K   7.9K   46  
Creates C code templates for PIC microcontrollers. The default templates are for use with the Hi-Tech (tm) PICC compiler.
#if !defined(_PICC_H_)
#define _PICC_H_

#include "typedefs.h"

extern volatile UINT16 timer1_clone;
extern void Sleep( UINT16 sleep_ms );
extern void putch( UBYTE byte_to_send );
extern UBYTE adc_continue( void );
extern void adc_init_channels( void );
extern UINT16 adc_read( UBYTE adc_ch );
extern void adc_start( UBYTE adc_ch );
extern UINT16 adc_get_adres( void );
extern UBYTE _EEPROMRead( UBYTE addr );
extern void EEPROMRead( UBYTE addr, UBYTE size, UBYTE* data );
extern void _EEPROMWrite( UBYTE addr, UBYTE data );
extern void EEPROMWrite( UBYTE addr, UBYTE size, UBYTE* data );

#define SET_OPTION(x)		OPTION = x
#define SET_INTCON(x)		INTCON = x
#define SET_T1CON(x)		T1CON = x

#define TIMER1_SETUP(x)		TIMER1_CONTROL = x
#define TIMER2_SETUP(x)		TIMER2_CONTROL = x
#define CCP1_SETUP(x)		CCP1_CONTROL = x
#define CCP2_SETUP(x)		CCP2_CONTROL = x
#define PWM_FREQ_SETUP(x)	PR2 = x
#define PWM1_DC_SETUP(x)	CCPR1L = x>>2; \
							CCP1X = 0; \
							CCP1Y = 0; \
							CCP1_CONTROL |= x<<4
#define PWM2_DC_SETUP(x)	CCPR2L = x>>2; \
							CCP2X = 0; \
							CCP2Y = 0; \
							CCP2_CONTROL |= x<<4
#define ADC_SETUP0(x)		ADCON0 = x
#define ADC_SETUP1(x)		ADCON1 = x

#endif // _PICC_H_

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Delphi
United States United States
Carlos Buelna works in the automotive industry.

Comments and Discussions