Purlvin's private Weblog ‹℘›

through the EyE, through the Life

CodeVisionAVR mega8515 MCS-51 compatible head file

好不容易买来一片AVR mega8515的片,立刻就去改学AVR,真是好东西啊。经过一番查找资料和学长的建议,终于认识到CodeVisionAVR C Compiler是编写AVR的好IDE,可惜找来找去都没有找到商业版,只下到了一个1.24的Evaluation。唉,库也不全,不过可以通过安装需要licence的商业版,然后把库拷出来得以解决。但是Evaluation却有2k的代码限制,这才是最郁闷的地方。虽然现在还没有写到那么大的程序,但是一点多个功能一叠加就必定会超过了。一想到这里,心中就很不爽。
唉,算了。多想也无益。自己好不容易又把mega8515的头文件改了一下,可以比较好的符合MCU-51的习惯了,具体如下(在“/**…**/”和“/**…**/”之间的是我自己加的):
// CodeVisionAVR C Compiler
// (C) 1998-2002 Pavel Haiduc, HP InfoTech S.R.L.
// I/O registers definitions for the ATmega8515(L)
#ifndef _MEGA8515_INCLUDED_
#define _MEGA8515_INCLUDED_
#pragma used+
sfrb OSCCAL=4;
sfrb PINE=5;
sfrb DDRE=6;
sfrb PORTE=7;
sfrb ACSR=8;
sfrb UBRRL=9;
sfrb UCSRB=0xa;
sfrb UCSRA=0xb;
sfrb UDR=0xc;
sfrb SPCR=0xd;
sfrb SPSR=0xe;
sfrb SPDR=0xf;
sfrb PIND=0x10;
sfrb DDRD=0x11;
sfrb PORTD=0x12;
sfrb PINC=0x13;
sfrb DDRC=0x14;
sfrb PORTC=0x15;
sfrb PINB=0x16;
sfrb DDRB=0x17;
sfrb PORTB=0x18;
sfrb PINA=0x19;
sfrb DDRA=0x1a;
sfrb PORTA=0x1b;
sfrb EECR=0x1c;
sfrb EEDR=0x1d;
sfrb EEARL=0x1e;
sfrb EEARH=0x1f;
sfrw EEAR=0x1e;   // 16 bit access
sfrb UBRRH=0x20;
sfrb UCSRC=0x20;
sfrb WDTCR=0x21;
sfrb ICR1L=0x24;
sfrb ICR1H=0x25;
sfrw ICR1=0x24;   // 16 bit access
sfrb OCR1BL=0x28;
sfrb OCR1BH=0x29;
sfrw OCR1B=0x28;  // 16 bit access
sfrb OCR1AL=0x2a;
sfrb OCR1AH=0x2b;
sfrw OCR1A=0x2a;  // 16 bit access
sfrb TCNT1L=0x2c;
sfrb TCNT1H=0x2d;
sfrw TCNT1=0x2c;  // 16 bit access
sfrb TCCR1B=0x2e;
sfrb TCCR1A=0x2f;
sfrb SFIOR=0x30;
sfrb OCR0=0x31;
sfrb TCNT0=0x32;
sfrb TCCR0=0x33;
sfrb MCUCSR=0x34;
sfrb MCUCR=0x35;
sfrb EMCUCR=0x36;
sfrb SPMCR=0x37;
sfrb TIFR=0x38;
sfrb TIMSK=0x39;
sfrb GIFR=0x3a;
sfrb GICR=0x3b;
sfrb SPL=0x3d;
sfrb SPH=0x3e;
sfrb SREG=0x3f;
#pragma used-
// Interrupt vectors definitions
#define EXT_INT0 2
#define EXT_INT1 3
#define TIM1_CAPT 4
#define TIM1_COMPA 5
#define TIM1_COMPB 6
#define TIM1_OVF 7
#define TIM0_OVF 8
#define SPI_STC 9
#define USART_RXC 10
#define USART_UDRE 11
#define USART_TXC 12
#define ANA_COMP 13
#define EXT_INT2 14
#define TIM0_COMP 15
#define EE_RDY 16
#define SPM_RDY 17
/***********************************************************************************/
// Data type definitions
#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long
// MCS-51 Modul definitions
sfrb DP0=0x1a;          //DDRA
sfrb P0=0x1b;           //PORTA
#define P0_0  P0.0
#define P0_1 P0.1
#define P0_2 P0.2
#define P0_3 P0.3
#define P0_4 P0.4
#define P0_5 P0.5
#define P0_6 P0.6
#define P0_7 P0.7
sfrb DP1=0x17;          //DDRB
sfrb P1=0x18;           //PORTB
#define P1_0  P1.0
#define P1_1 P1.1
#define P1_2 P1.2
#define P1_3 P1.3
#define P1_4 P1.4
#define P1_5 P1.5
#define P1_6 P1.6
#define P1_7 P1.7
sfrb DP2=0x14;          //DDRC
sfrb P2=0x15;           //PORTA
#define P2_0  P2.0
#define P2_1 P2.1
#define P2_2 P2.2
#define P2_3 P2.3
#define P2_4 P2.4
#define P2_5 P2.5
#define P2_6 P2.6
#define P2_7 P2.7
sfrb DP3=0x11;          //DDRD
sfrb P3=0x12;           //PORTD
#define P3_0  P3.0
#define P3_1 P3.1
#define P3_2 P3.2
#define P3_3 P3.3
#define P3_4 P3.4
#define P3_5 P3.5
#define P3_6 P3.6
#define P3_7 P3.7
#define RXD  P3.0
#define TXD P3.1
#define INT0 P3.2
#define INT1 P3.3
#define T0 P3.4
#define T1 P3.5
#define WR P3.6
#define RD P3.7
sfrb DP4=6;             //DDRE
sfrb P4=7;              //PORTE
#define P4_0  P4.0
#define P4_1 P4.1
#define P4_2 P4.2
#define EA  P4.0
#define ALE P4.1
#define PSEN P4.2
/***********************************************************************************/
#endif

好不容易买来一片AVR mega8515的片,立刻就去改学AVR,真是好东西啊。经过一番查找资料和学长的建议,终于认识到CodeVisionAVR C Compiler是编写AVR的好IDE,可惜找来找去都没有找到商业版,只下到了一个1.24的Evaluation。唉,库也不全,不过可以通过安装需要licence的商业版,然后把库拷出来得以解决。但是Evaluation却有2k的代码限制,这才是最郁闷的地方。虽然现在还没有写到那么大的程序,但是一点多个功能一叠加就必定会超过了。一想到这里,心中就很不爽。唉,算了。多想也无益。自己好不容易又把mega8515的头文件改了一下,可以比较好的符合MCU-51的习惯了,具体如下(在“/**…**/”和“/**…**/”之间的是我自己加的):// CodeVisionAVR C Compiler// (C) 1998-2002 Pavel Haiduc, HP InfoTech S.R.L.// I/O registers definitions for the ATmega8515(L)#ifndef _MEGA8515_INCLUDED_#define _MEGA8515_INCLUDED_ #pragma used+sfrb OSCCAL=4;sfrb PINE=5;sfrb DDRE=6;sfrb PORTE=7;sfrb ACSR=8;sfrb UBRRL=9;sfrb UCSRB=0xa;sfrb UCSRA=0xb;sfrb UDR=0xc;sfrb SPCR=0xd;sfrb SPSR=0xe;sfrb SPDR=0xf;sfrb PIND=0x10;sfrb DDRD=0x11;sfrb PORTD=0x12;sfrb PINC=0x13;sfrb DDRC=0x14;sfrb PORTC=0x15;sfrb PINB=0x16;sfrb DDRB=0x17;sfrb PORTB=0x18;sfrb PINA=0x19;sfrb DDRA=0x1a;sfrb PORTA=0x1b;sfrb EECR=0x1c;sfrb EEDR=0x1d;sfrb EEARL=0x1e;sfrb EEARH=0x1f;sfrw EEAR=0x1e;   // 16 bit accesssfrb UBRRH=0x20;sfrb UCSRC=0x20;sfrb WDTCR=0x21;sfrb ICR1L=0x24;sfrb ICR1H=0x25;sfrw ICR1=0x24;   // 16 bit accesssfrb OCR1BL=0x28;sfrb OCR1BH=0x29;sfrw OCR1B=0x28;  // 16 bit accesssfrb OCR1AL=0x2a;sfrb OCR1AH=0x2b;sfrw OCR1A=0x2a;  // 16 bit accesssfrb TCNT1L=0x2c;sfrb TCNT1H=0x2d;sfrw TCNT1=0x2c;  // 16 bit accesssfrb TCCR1B=0x2e;sfrb TCCR1A=0x2f;sfrb SFIOR=0x30;sfrb OCR0=0x31;sfrb TCNT0=0x32;sfrb TCCR0=0x33;sfrb MCUCSR=0x34;sfrb MCUCR=0x35;sfrb EMCUCR=0x36;sfrb SPMCR=0x37;sfrb TIFR=0x38;sfrb TIMSK=0x39;sfrb GIFR=0x3a;sfrb GICR=0x3b;sfrb SPL=0x3d;sfrb SPH=0x3e;sfrb SREG=0x3f;#pragma used-// Interrupt vectors definitions#define EXT_INT0 2#define EXT_INT1 3#define TIM1_CAPT 4#define TIM1_COMPA 5#define TIM1_COMPB 6#define TIM1_OVF 7#define TIM0_OVF 8#define SPI_STC 9#define USART_RXC 10#define USART_UDRE 11#define USART_TXC 12#define ANA_COMP 13#define EXT_INT2 14#define TIM0_COMP 15#define EE_RDY 16#define SPM_RDY 17/***********************************************************************************/// Data type definitions#define uchar unsigned char#define uint unsigned int #define ulong unsigned long// MCS-51 Modul definitionssfrb DP0=0x1a;          //DDRAsfrb P0=0x1b;           //PORTA#define P0_0  P0.0#define P0_1 P0.1#define P0_2 P0.2#define P0_3 P0.3#define P0_4 P0.4#define P0_5 P0.5#define P0_6 P0.6#define P0_7 P0.7sfrb DP1=0x17;          //DDRBsfrb P1=0x18;           //PORTB#define P1_0  P1.0#define P1_1 P1.1#define P1_2 P1.2#define P1_3 P1.3#define P1_4 P1.4#define P1_5 P1.5#define P1_6 P1.6#define P1_7 P1.7sfrb DP2=0x14;          //DDRCsfrb P2=0x15;           //PORTA#define P2_0  P2.0#define P2_1 P2.1#define P2_2 P2.2#define P2_3 P2.3#define P2_4 P2.4#define P2_5 P2.5#define P2_6 P2.6#define P2_7 P2.7sfrb DP3=0x11;          //DDRDsfrb P3=0x12;           //PORTD#define P3_0  P3.0#define P3_1 P3.1#define P3_2 P3.2#define P3_3 P3.3#define P3_4 P3.4#define P3_5 P3.5#define P3_6 P3.6#define P3_7 P3.7#define RXD  P3.0#define TXD P3.1#define INT0 P3.2#define INT1 P3.3#define T0 P3.4#define T1 P3.5#define WR P3.6#define RD P3.7sfrb DP4=6;             //DDREsfrb P4=7;              //PORTE#define P4_0  P4.0#define P4_1 P4.1#define P4_2 P4.2#define EA  P4.0#define ALE P4.1#define PSEN P4.2                                                                /***********************************************************************************/#endif

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: