lcd pinleri değiştirmek

Başlatan armsistem, 24 Mayıs 2012, 11:56:42

armsistem

Arkadaşlar merhaba aşağıda lcd port pinleri P0.4-P0.5-P0.6-P0.7 ne yaparsam yapayım portları kaydıramadım gözden kaçırdığım nokta neresi.
#define  LCD_D4  0x10   //P0.04
#define  LCD_D5  0x20   //P0.05
#define  LCD_D6  0x40   //P0.06
#define  LCD_D7  0x80   //P0.07


Örnek : LCD_D4 = 0x10 (hex)----> 00010000  ---- LPC2104 'nın P0.4


Kodun Tamamı


#include "lcd.h"
#include "lpc210x.h"

void lcd_wait(){
      int loop=2800;  //more than enough
      //busy loop
      while(loop--);
}

void lcd_out_data4(unsigned char val){
     IOCLR |= (LCD_DATA);
     IOSET |= (val<<4);
}

void lcd_write_nibbles(unsigned char val){

     //higher-order byte
     lcd_en_set();
     lcd_out_data4((val>>4)&0x0F);
     lcd_en_clr();

     lcd_wait();

     //lower-order byte
     lcd_en_set();
     lcd_out_data4((val)&0x0F);
     lcd_en_clr();
     
     lcd_wait();
}

/***********************************
Mehmet Ekledi..  Lcd_gotoxy
************************************/

/*
 * Go to the specified position
 */

void
lcd_goto(unsigned char pos)
{
	lcd_rs_clr();
	lcd_write_nibbles(0x80+pos);
}
//************* Eklenen Fonksiyon ***********

void lcd_write_control(unsigned char val){
     lcd_rs_clr();
     lcd_write_nibbles(val);
}

void lcd_init(){

        PINSEL0 &= (~LCD_GPIO_SEL0);
        PINSEL1 &= (~LCD_GPIO_SEL1);
        /* we only work on OUTPUT so far */
        IODIR |= LCD_IOALL;
        
        /* IO init complete, init LCD */

       /* init 4-bit ops*/
       lcd_rs_clr();
       lcd_rw_clr();
       lcd_en_clr();


       //wait VDD raise > 4.5V
       lcd_wait();
       
       //dummy inst 
       lcd_write_nibbles(0x30);
       lcd_write_nibbles(0x30);
       lcd_write_nibbles(0x30);

       //FUNCTION SET
       //001DL  N F XX
       //DL=1: 8bit
       //DL=0: 4bit
       //N=0: 1 line display
       //N=1: 2 line display
       //F=0: 5x7 dots
       //F=1: 5x10 dots

       //our case:
       //0010 1000
       lcd_en_set();
       lcd_out_data4(0x2);
       lcd_en_clr();
       lcd_wait();

       lcd_write_nibbles(0x28);
       
       //LCD ON
       lcd_write_nibbles(0x0E);

       //Clear Display
       lcd_write_nibbles(0x01);

       //Entry mode
       lcd_write_nibbles(0x06);

}

void lcd_putchar(unsigned char c){

       lcd_rs_set();
       lcd_write_nibbles(c);
}

void lcd_print(unsigned char* str){
      int i;


      //limit 1 line display for prints
        for (i=0;i<16 && str[i]!=0;i++){
                lcd_putchar(str[i]);
        }

}


// Copyright (c) 2004 senz at arm.dreamislife.com
//
//
// THIS FILE IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.

/***************************************/
/* LCD routines for OLIMEX LPC-MT-2106 */
/* 16x2 Character LCD 1602K            */
/* 4-bit mode operation                */
/***************************************/


/* DEFINE IOMASK */
#define  LCD_D4  0x10   //P0.04
#define  LCD_D5  0x20   //P0.05
#define  LCD_D6  0x40   //P0.06
#define  LCD_D7  0x80   //P0.07
#define  LCD_EN  0x400000   //P0.22
#define  LCD_RS  0x800000   //P0.23
#define  LCD_RW  0x1000000  //P0.24

#define  LCD_DATA           (LCD_D4|LCD_D5|LCD_D6|LCD_D7)
#define  LCD_IOALL          (LCD_D4|LCD_D5|LCD_D6|LCD_D7|LCD_EN|LCD_RS|LCD_RW)

#define  LCD_GPIO_SEL0      0x0000FF00   //MASK for P0.04-P0.07
#define  LCD_GPIO_SEL1      0x0003F000   //MASK for P0.22-P0.24


/* Functions Header */
/* internal I/O functions */
#define lcd_rs_set() IOSET |= LCD_RS
#define lcd_rs_clr() IOCLR |= LCD_RS
#define lcd_en_set() IOSET |= LCD_EN
#define lcd_en_clr() IOCLR |= LCD_EN
#define lcd_rw_set() IOSET |= LCD_RW
#define lcd_rw_clr() IOCLR |= LCD_RW

/* wait until lcd controller is free */
void lcd_wait(void);
void lcd_out_data4(unsigned char);
void lcd_write_nibbles(unsigned char);
void lcd_write_control(unsigned char);



/* initialize both the GPIO of lpc and LCD */
void lcd_init(void);

#define lcd_clear()         lcd_write_control(0x01)
#define lcd_cursor_home()   lcd_write_control(0x02)

#define lcd_display_on()    lcd_write_control(0x0E)
#define lcd_display_off()   lcd_write_control(0x08)

#define lcd_cursor_blink()  lcd_write_control(0x0F)
#define lcd_cursor_on()     lcd_write_control(0x0E)
#define lcd_cursor_off()    lcd_write_control(0x0C)

#define lcd_cursor_left()   lcd_write_control(0x10)
#define lcd_cursor_right()  lcd_write_control(0x14)
#define lcd_display_sleft() lcd_write_control(0x18)
#define lcd_display_sright() lcd_write_control(0x1C)



/* put a character out to lcd */
void lcd_putchar(unsigned char);
/* print a string */
void lcd_print(unsigned char*);
								 
/* Go to the specified position */

extern void lcd_goto(unsigned char pos);
	



//----------------------------------

#define	S1_1	   		0x00 
#define	S1_2	   		0x01 
#define	S1_3	   		0x02 
#define	S1_4	   		0x03 
#define	S1_5	   		0x04 
#define	S1_6	   		0x05 
#define	S1_7	   		0x06 
#define	S1_8	   		0x07 
#define	S1_9	   		0x08 
#define	S1_10	   		0x09 
#define	S1_11	   		0x0A 
#define	S1_12	   		0x0B 
#define	S1_13	   		0x0C 
#define	S1_14	   		0x0D 
#define	S1_15	   		0x0E 
#define	S1_16	   		0x0F 
#define	S1_17	   		0x10 
#define	S1_18	   		0x11 
#define	S1_19	   		0x12 
#define	S1_20	   		0x13 

//----------------------------------

#define	S2_1	   		0x40 
#define	S2_2	   		0x41 
#define	S2_3	   		0x42 
#define	S2_4	   		0x43 
#define	S2_5	   		0x44 
#define	S2_6	   		0x45 
#define	S2_7	   		0x46 
#define	S2_8	   		0x47 
#define	S2_9	   		0x48 
#define	S2_10	   		0x49 
#define	S2_11	   		0x4A 
#define	S2_12	   		0x4B 
#define	S2_13	   		0x4C 
#define	S2_14	   		0x4D 
#define	S2_15	   		0x4E 
#define	S2_16	   		0x4F 
#define	S2_17	   		0x50 
#define	S2_18	   		0x51 
#define	S2_19	   		0x52 
#define	S2_20	   		0x53 

//----------------------------------

#define	S3_1	   		0x14 
#define	S3_2	   		0x15 
#define	S3_3	   		0x16 
#define	S3_4	   		0x17 
#define	S3_5	   		0x18 
#define	S3_6	   		0x19 
#define	S3_7	   		0x1A 
#define	S3_8	   		0x1B 
#define	S3_9	   		0x1C 
#define	S3_10	   		0x1D 
#define	S3_11	   		0x1E 
#define	S3_12	   		0x1F 
#define	S3_13	   		0x20 
#define	S3_14	   		0x21 
#define	S3_15	   		0x22 
#define	S3_16	   		0x23 
#define	S3_17	   		0x24 
#define	S3_18	   		0x25 
#define	S3_19	   		0x26 
#define	S3_20	   		0x27 

//----------------------------------

#define	S4_1	   		0x54 
#define	S4_2	   		0x55 
#define	S4_3	   		0x56 
#define	S4_4	   		0x57 
#define	S4_5	   		0x58 
#define	S4_6	   		0x59 
#define	S4_7	   		0x5A 
#define	S4_8	   		0x5B 
#define	S4_9	   		0x5C 
#define	S4_10	   		0x5D 
#define	S4_11	   		0x5E 
#define	S4_12	   		0x5F 
#define	S4_13	   		0x60 
#define	S4_14	   		0x61 
#define	S4_15	   		0x62 
#define	S4_16	   		0x63 
#define	S4_17	   		0x64 
#define	S4_18	   		0x65 
#define	S4_19	   		0x66 
#define	S4_20	   		0x67 

mozkan87

#define  LCD_GPIO_SEL0      0x0000FF00   //MASK for P0.04-P0.07 
#define  LCD_GPIO_SEL1      0x0003F000   //MASK for P0.22-P0.24


Yukarıdaki 2 satırıda uygun şekilde değiştirdiniz mi? Birde bu dosyalar bu haliyle çalışıyor değil mi?
#define  LCD_D4  0x10   //P0.04 #define  LCD_D5  0x20   //P0.05 #define  LCD_D6  0x40   //P0.06 #define  LCD_D7  0x80   //P0.07

bu satırları mı değiştirdiniz sadece.

armsistem

Evet iki satırıda değiştirdim.