694789602 发表于 2009-10-25 22:07:03

请问马老师您书中例6—8(lcd)的一些问题

您书中程序写的晶振频率是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
/*   
    1 GND- 9GND
    2 +5V- 10 VCC
    3 VLC- LCD HEADER Vo
    4 RS - 1PC0 (M16)
    5 RD - 2PC1 (M16)
    6 EN - 3PC2 (M16)
   11 D4 - 5PC4 (M16)
   12 D5 - 6PC5 (M16)
   13 D6 - 7PC6 (M16)
   14 D7 - 8PC7 (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的。请高人指点!谢谢

machao 发表于 2009-10-26 15:50:38

与频率无关。

因为该例使用了PORTC口,所以要正确配置熔丝位,禁止PORTC上的JTAG口,把4个引脚作为GPIO使用。

这个例子来自CVAVR中HELP的例子。如果需要使用JTAG口仿真调试,可以将LCD换到其它的口上,如使用PORTA。

注意:使用CVAVR中内置的LCD函数,LCD的接口不能跨接口连接,所有的连接必须是在一个PORT口上

694789602 发表于 2009-10-26 19:56:26

谢谢马老师!问题解决了,我将JTAG使能了,熔丝位配置错了。嘿嘿,打扰了

FPGADSPSOCASIC 发表于 2010-4-18 16:34:04

马老师,你太帅了,我也遇到这个问题,感谢马老师!
页: [1]
查看完整版本: 请问马老师您书中例6—8(lcd)的一些问题