⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pic18fxx39.h

📁 PIC单片机PICC环境下PIC18Fxx39系列通用头文件
💻 H
📖 第 1 页 / 共 2 页
字号:
/* Definitions for TRISB register */
static volatile near bit	TRISB0		@ ((unsigned)&TRISB*8)+0;
static volatile near bit	TRISB1		@ ((unsigned)&TRISB*8)+1;
static volatile near bit	TRISB2		@ ((unsigned)&TRISB*8)+2;
static volatile near bit	TRISB3		@ ((unsigned)&TRISB*8)+3;
static volatile near bit	TRISB4		@ ((unsigned)&TRISB*8)+4;
static volatile near bit	TRISB5		@ ((unsigned)&TRISB*8)+5;
static volatile near bit	TRISB6		@ ((unsigned)&TRISB*8)+6;
static volatile near bit	TRISB7		@ ((unsigned)&TRISB*8)+7;

/* Definitions for TRISA register */
static volatile near bit	TRISA0		@ ((unsigned)&TRISA*8)+0;
static volatile near bit	TRISA1		@ ((unsigned)&TRISA*8)+1;
static volatile near bit	TRISA2		@ ((unsigned)&TRISA*8)+2;
static volatile near bit	TRISA3		@ ((unsigned)&TRISA*8)+3;
static volatile near bit	TRISA4		@ ((unsigned)&TRISA*8)+4;
static volatile near bit	TRISA5		@ ((unsigned)&TRISA*8)+5;
static volatile near bit	TRISA6		@ ((unsigned)&TRISA*8)+6;

#if defined(_18F4439) || defined(_18F4539)
/* Definitions for LATE register */
static volatile near bit	LATE0		@ ((unsigned)&LATE*8)+0;
static volatile near bit	LATE1		@ ((unsigned)&LATE*8)+1;
static volatile near bit	LATE2		@ ((unsigned)&LATE*8)+2;

/* Definitions for LATD register */
static volatile near bit	LATD0		@ ((unsigned)&LATD*8)+0;
static volatile near bit	LATD1		@ ((unsigned)&LATD*8)+1;
static volatile near bit	LATD2		@ ((unsigned)&LATD*8)+2;
static volatile near bit	LATD3		@ ((unsigned)&LATD*8)+3;
static volatile near bit	LATD4		@ ((unsigned)&LATD*8)+4;
static volatile near bit	LATD5		@ ((unsigned)&LATD*8)+5;
static volatile near bit	LATD6		@ ((unsigned)&LATD*8)+6;
static volatile near bit	LATD7		@ ((unsigned)&LATD*8)+7;
#endif

/* Definitions for LATC register */
static volatile near bit	LATC0		@ ((unsigned)&LATC*8)+0;
static volatile near bit	LATC3		@ ((unsigned)&LATC*8)+3;
static volatile near bit	LATC4		@ ((unsigned)&LATC*8)+4;
static volatile near bit	LATC5		@ ((unsigned)&LATC*8)+5;
static volatile near bit	LATC6		@ ((unsigned)&LATC*8)+6;
static volatile near bit	LATC7		@ ((unsigned)&LATC*8)+7;

/* Definitions for LATB register */
static volatile near bit	LATB0		@ ((unsigned)&LATB*8)+0;
static volatile near bit	LATB1		@ ((unsigned)&LATB*8)+1;
static volatile near bit	LATB2		@ ((unsigned)&LATB*8)+2;
static volatile near bit	LATB3		@ ((unsigned)&LATB*8)+3;
static volatile near bit	LATB4		@ ((unsigned)&LATB*8)+4;
static volatile near bit	LATB5		@ ((unsigned)&LATB*8)+5;
static volatile near bit	LATB6		@ ((unsigned)&LATB*8)+6;

/* Definitions for LATA register */
static volatile near bit	LATA0		@ ((unsigned)&LATA*8)+0;
static volatile near bit	LATA1		@ ((unsigned)&LATA*8)+1;
static volatile near bit	LATA2		@ ((unsigned)&LATA*8)+2;
static volatile near bit	LATA3		@ ((unsigned)&LATA*8)+3;
static volatile near bit	LATA4		@ ((unsigned)&LATA*8)+4;
static volatile near bit	LATA5		@ ((unsigned)&LATA*8)+5;
static volatile near bit	LATA6		@ ((unsigned)&LATA*8)+6;

#if defined(_18F4439) || defined(_18F4539)
/* Definitions for PORTE register */
static volatile near bit	RE0		@ ((unsigned)&PORTE*8)+0;
static volatile near bit	RE1		@ ((unsigned)&PORTE*8)+1;
static volatile near bit	RE2		@ ((unsigned)&PORTE*8)+2;

/* Definitions for PORTD register */
static volatile near bit	RD0		@ ((unsigned)&PORTD*8)+0;
static volatile near bit	RD1		@ ((unsigned)&PORTD*8)+1;
static volatile near bit	RD2		@ ((unsigned)&PORTD*8)+2;
static volatile near bit	RD3		@ ((unsigned)&PORTD*8)+3;
static volatile near bit	RD4		@ ((unsigned)&PORTD*8)+4;
static volatile near bit	RD5		@ ((unsigned)&PORTD*8)+5;
static volatile near bit	RD6		@ ((unsigned)&PORTD*8)+6;
static volatile near bit	RD7		@ ((unsigned)&PORTD*8)+7;
#endif

/* Definitions for PORTC register */
static volatile near bit	RC0		@ ((unsigned)&PORTC*8)+0;
static volatile near bit	RC3		@ ((unsigned)&PORTC*8)+3;
static volatile near bit	RC4		@ ((unsigned)&PORTC*8)+4;
static volatile near bit	RC5		@ ((unsigned)&PORTC*8)+5;
static volatile near bit	RC6		@ ((unsigned)&PORTC*8)+6;
static volatile near bit	RC7		@ ((unsigned)&PORTC*8)+7;

/* Definitions for PORTB register */
static volatile near bit	RB0		@ ((unsigned)&PORTB*8)+0;
static volatile near bit	RB1		@ ((unsigned)&PORTB*8)+1;
static volatile near bit	RB2		@ ((unsigned)&PORTB*8)+2;
static volatile near bit	RB3		@ ((unsigned)&PORTB*8)+3;
static volatile near bit	RB4		@ ((unsigned)&PORTB*8)+4;
static volatile near bit	RB5		@ ((unsigned)&PORTB*8)+5;
static volatile near bit	RB6		@ ((unsigned)&PORTB*8)+6;
static volatile near bit	RB7		@ ((unsigned)&PORTB*8)+7;

/* Definitions for PORTA register */
static volatile near bit	RA0		@ ((unsigned)&PORTA*8)+0;
static volatile near bit	RA1		@ ((unsigned)&PORTA*8)+1;
static volatile near bit	RA2		@ ((unsigned)&PORTA*8)+2;
static volatile near bit	RA3		@ ((unsigned)&PORTA*8)+3;
static volatile near bit	RA4		@ ((unsigned)&PORTA*8)+4;
static volatile near bit	RA5		@ ((unsigned)&PORTA*8)+5;
static volatile near bit	RA6		@ ((unsigned)&PORTA*8)+6;


#define EEPROM_SIZE 256

#if defined(_18F2439) || defined(_18F4439)
#define ROMSIZE 12288
#else
#define ROMSIZE 24576
#endif

// Configuration Bit Values

// Configuration register 1
 #define HSPLL		0xF6FF 	// HS with PLL enabled 
 #define ECIO		0xF5FF 	// EC, RA6=IO 
 #define ECCLKO		0xF4FF 	// EC, RA6=CLKOUT 
 #define HS		0xF2FF 	// HS osc 

// Configuration register 2
 #define BOREN		0xFFFF 	// included only for completeness 
 #define BORDIS		0xFFFD 	// Brown out reset disabled 
 #define BORV45		0xFFF3 	// Brown out reset enabled, reset at 4.5V 
 #define BORV42		0xFFF7 	// Brown out reset enabled, reset at 4.2V 
 #define BORV27		0xFFFB 	// Brown out reset enabled, reset at 2.7V 
 #define BORV25		0xFFFF 	// Brown out reset enabled, reset at 2.5V 
 #define PWRTEN		0xFFFE 	// Power-up timer enable 
 #define PWRTDIS	0xFFFF 	// Power-up timer disable 
 #define WDTPS1		0xF1FF 	// Watchdog timer enabled with prescaler(s) 
 #define WDTPS2		0xF3FF 
 #define WDTPS4		0xF5FF 
 #define WDTPS8		0xF7FF 
 #define WDTPS16	0xF9FF 
 #define WDTPS32	0xFBFF 
 #define WDTPS64	0xFDFF 
 #define WDTPS128	0xFFFF 
 #define WDTDIS		0xFEFF 	// Watchdog timer disabled 
 #define WDTEN		0xFFFF 	// included only for completeness 

// Configuration register 4
 #define DEBUGEN	0xFF7F 	// Debugger enabled 
 #define DEBUGDIS	0xFFFF 	// Debugger disabled 
 #define LVPEN		0xFFFF 	// Low voltage ISP enabled 
 #define LVPDIS		0xFFFB 	// Low voltage ISP disabled 
 #define STVREN		0xFFFF 	// Stack over/underflow will cause reset 
 #define STVRDIS	0xFFFE 	// Stack over/underflow will not cause reset 

// Configuration register 5
#if defined(_18F2539) || defined(_18F4539)
 #define CPALL		0x3FF8 	// Protect all of the above 
 #define CPA		0xFFF8 	// Protect program memory sections 
 #define CP2		0xFFFB 	// Protect program memory block 2 
#else
 #define CPALL		0x3FFC 	// Protect all of the above 
 #define CPA		0xFFFC 	// Protect program memory sections 
#endif
 #define CP1		0xFFFD 	// Protect program memory block 1 
 #define CP0		0xFFFE 	// Protect program memory block 0 
 #define CPD		0x7FFF 	// Protect EEPROM data 
 #define CPB		0xBFFF 	// Protect boot block 
 #define UNPROTECT	0xFFFF 	// Do not protect memory 

// Configuration register 6
#if defined(_18F2539) || defined(_18F4539)
 #define WPALL		0x1FF8 	// Write protect all of the above 
 #define WPA		0xFFF8 	// Write protect program memory sections 
 #define WP2		0xFFFB 	// Write protect program memory block 2 
#else
 #define WPALL		0x1FFC 	// Write protect all of the above 
 #define WPA		0xFFFC 	// Write protect program memory sections 
#endif
 #define WP1		0xFFFD 	// Write protect program memory block 1 
 #define WP0		0xFFFE 	// Write protect program memory block 0 
 #define WPD		0x7FFF 	// Write protect EEPROM data 
 #define WPB		0xBFFF 	// Write protect boot block 
 #define WPC		0xDFFF 	// Write protect configuration registers 
 #define WRTEN		0xFFFF 	// Write enabled 

// Configuration register 7
#if defined(_18F2539) || defined(_18F4539)
 #define TRPALL		0xBFF8 	// Table read protect all of the above 
 #define TRPA		0xFFF8 	// Table read protect program memory sections 
 #define TRP2		0xFFFB 	// Table read protect program memory block 2 
#else
 #define TRPALL		0xBFFC 	// Table read protect all of the above 
 #define TRPA		0xFFFC 	// Table read protect program memory sections 
#endif
 #define TRP1		0xFFFD 	// Table read protect program memory block 1 
 #define TRP0		0xFFFE 	// Table read protect program memory block 0 
 #define TRPB		0xBFFF 	// Table read protect boot block 


/* The following definitions are to enable */
/* access to the built-in ProMPT APIs which */
/* reside on these chips */

#ifndef	_PIC18_H_
#include <pic18.h>
#endif

/* the index into the ProMPT vector table */
#define __clearTick			1
#define __disableBoostMode		2
#define __enableBoostMode		3
#define __getFrequency			4
#define __getModulation			5
#define __Init				6
#define __setAccelRate			7
#define __setBoostEndModulation		8
#define __setBoostFrequency		9
#define __setBoostStartModulation	10
#define __setBoostTime			11
#define __setDecelRate			12
#define __setFrequency			13
#define __setLineVoltage		14
#define __setMotorVoltage		15
#define __setPWMfrequency		16
#define __setVFcurve			17
#define __getVFcurve			18
#define __Start				19
#define __Stop				20
#define __Tick				21
#define __setParameter			22
#define __getParameter			23
#define __getAccelRate			24
#define __getBoostEndModulation		25
#define __getBoostFrequency		26
#define __getBoostStartModulation	27
#define __getBoostTime			28
#define __getDecelRate			29

/* definitions of specific addresses */
#if defined(_18F2539) || defined(_18F4539)
#define __PROMPT	0x6000
static unsigned char	PARAM1	@ 0x05C0;
static unsigned char	PARAM2	@ 0x05C1;
#else
#define __PROMPT	0x3000
static unsigned char	PARAM1	@ 0x02C0;
static unsigned char	PARAM2	@ 0x02C1;
#endif

/* ProMPT requires exclusive access to the high priority ISR */
#define __RESERVE_INTERRUPT	\
asm("psect intcode");		\
asm("	goto	" ___mkstr(__PROMPT+4)); \
asm("psect text")

/* calls to ProMPT APIs */
#define ProMPT_ClearTick()		\
	(*((void(*)(char))__PROMPT))(__clearTick)
	
#define ProMPT_DisableBoostMode()	\
	(*((void(*)(char))__PROMPT))(__disableBoostMode)
	
#define ProMPT_EnableBoostMode()	\
	(*((void(*)(char))__PROMPT))(__enableBoostMode)
	
#define ProMPT_GetAccelRate()		\
	(*((char(*)(char))__PROMPT))(__getAccelRate)

#define ProMPT_GetBoostEndModulation()	\
	(*((char(*)(char))__PROMPT))(__getBoostEndModulation)
	
#define ProMPT_GetBoostFrequency()	\
	(*((char(*)(char))__PROMPT))(__getBoostFrequency)

#define ProMPT_GetBoostStartModulation()\
	(*((char(*)(char))__PROMPT))(__getBoostStartModulation)

#define ProMPT_GetDecelRate()		\
	(*((char(*)(char))__PROMPT))(__getDecelRate)

#define ProMPT_GetFrequency()		\
	(*((char(*)(char))__PROMPT))(__getFrequency)

#define ProMPT_GetModulation()		\
	(*((char(*)(char))__PROMPT))(__getModulation)

#define ProMPT_GetParameter( parameter )	\
	PARAM1=(parameter);		\
	(*((char(*)(char))__PROMPT))(__getParameter)

#define ProMPT_Init( PWMfrequency )	\
	__RESERVE_INTERRUPT;		\
	PARAM1=(PWMfrequency);		\
	(*((void(*)(char))__PROMPT))(__Init)

#define ProMPT_SetAccelRate( rate )	\
	PARAM1=(rate);			\
	(*((void(*)(char))__PROMPT))(__setAccelRate)

#define ProMPT_SetBoostEndModulation( modulation )	\
	PARAM1=(modulation);		\
	(*((void(*)(char))__PROMPT))(__setBoostEndModulation)
	
#define ProMPT_SetBoostFrequency( frequency )	\
	PARAM1=(frequency);		\
	(*((char(*)(char))__PROMPT))(__setBoostFrequency)
	
#define ProMPT_SetBoostStartModulation( modulation )	\
	PARAM1=(modulation);		\
	(*((void(*)(char))__PROMPT))(__setBoostStartModulation)

#define ProMPT_SetBoostTime( time )	\
	PARAM1=(time);			\
	(*((void(*)(char))__PROMPT))(__setBoostTime)

#define ProMPT_SetDecelRate( rate )	\
	PARAM1=(rate);			\
	(*((void(*)(char))__PROMPT))(__setDecelRate)
	
#define ProMPT_SetFrequency( frequency )	\
	PARAM1=(frequency);		\
	(*((char(*)(char))__PROMPT))(__setFrequency)

#define ProMPT_SetLineVoltage( voltage )	\
	PARAM1=(voltage);			\
	(*((void(*)(char))__PROMPT))(__setLineVoltage)

#define ProMPT_SetMotorVoltage( voltage )	\
	PARAM1=(voltage);			\
	(*((void(*)(char))__PROMPT))(__setMotorVoltage)

#define ProMPT_SetPWMfrequency( frequency )	\
	PARAM1=(frequency);		\
	(*((void(*)(char))__PROMPT))(__setPWMfrequency)

#define ProMPT_SetVFCurve( point, value )	\
	PARAM2=(point);			\
	PARAM1=(value);			\
	(*((void(*)(char))__PROMPT))(__setVFcurve)

#define ProMPT_getVFCurve( point )	\
	PARAM1=(point);			\
	(*((char(*)(char))__PROMPT))(__getVFcurve)
	
#define ProMPT_SetParameter( parameter, value )	\
	PARAM2=(parameter);		\
	PARAM1=(value);			\
	(*((void(*)(char))__PROMPT))(__setParameter)

#define ProMPT_Start()			\
	(*((void(*)(char))__PROMPT))(__Start)

#define ProMPT_Stop()			\
	(*((void(*)(char))__PROMPT))(__Stop)

#define ProMPT_Tick()			\
	(*((char(*)(char))__PROMPT))(__Tick)

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -