|
您书中程序写的晶振频率是4MHZ,请问必须用4M的吗?用其他频率的话,程序需要作哪些改动吗?
/*********************************************
File name : demo_6_8.c
Chip type : ATmega16
Program type : Application
Clock frequency : 4.000000 MHz
Memory model : Small
External SRAM size : 0
Data Stack size : 256
*********************************************/
#include <mega16.h>
#include <delay.h>
#asm
.equ __lcd_port=0x15 ; PORTC数据寄存器地址
#endasm
/* [LCD]
1 GND- 9 GND
2 +5V- 10 VCC
3 VLC- LCD HEADER Vo
4 RS - 1 PC0 (M16)
5 RD - 2 PC1 (M16)
6 EN - 3 PC2 (M16)
11 D4 - 5 PC4 (M16)
12 D5 - 6 PC5 (M16)
13 D6 - 7 PC6 (M16)
14 D7 - 8 PC7 (M16) */
#include <lcd.h>
flash unsigned char dis_str[]="Hello World! This is a LCD display demo.";
void main(void)
{
unsigned char flash *str;
str = dis_str;
lcd_init(16); // initialize the LCD for 2 lines & 16 columns
while(1)
{
lcd_clear(); // clere the LCD
lcd_putsf("It's demo_6_8.c"); // display the message
lcd_gotoxy(0,0); // go on the second LCD line
lcd_putsf(str); // display the message
if (*str++ == 0) str = dis_str;
delay_ms(500);
}
}
我就按这个做的,可是没能成功,接线图与书上的一样,晶振用内部4M的。请高人指点!谢谢 |
|