• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
  • slider image 488
  • slider image 491
:::


Browsing this Thread:   1 Anonymous Users






Re: LCD pin define
#9
中級會員
中級會員


查看用戶資訊
謝謝各位先進的回應
小弟已經成功將程式轉移了
再次感謝

發表於: 2007/10/1 17:48
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: LCD pin define
#8
資深會員
資深會員


查看用戶資訊
RD0 => RD2
RD1 => RD3
RD2 => RD4
RD3 => RD5

你這樣的更換真的很糟糕..程式必需要修改很多地方才能配合你的電路了...

// Write Command to LCD module
//
void WriteCmdLCDunsigned char LCD_CMD
{
    
Temp_CMD = (LCD_CMD 0xF0)[color=0000CC]>>2[/color] ;            // Send high nibble to LCD bus
    
LCD_DATA= (LCD_DATA & [color=0000CC]0b11000011[/color])|Temp_CMD ;
    
LCD_CMD_W_Timing () ;

    
Temp_CMD = (LCD_CMD 0xF0)[color=0000CC]<<2[/color] ;  ;             // Send low nibble to LCD bus
    
LCD_DATA= (LCD_DATA & [color=0000CC]0b11000011[/color])|Temp_CMD ;
    
LCD_CMD_W_Timing () ;

    
LCD_S_Delay() ;                         // Delay 100uS for execution
}

//***********************************************
// Write Data to LCD module
//
void WriteDataLCDunsigned char LCD_CMD
{
    
Buf_LATD LCD_DATA ;
    
    
Temp_CMD = (LCD_CMD 0xF0)[color=0000CC]>>2[/color] ;            // Send high nibble to LCD bus    

    
LCD_DATA= (LCD_DATA & [color=0000CC]0b11000011[/color])|Temp_CMD ;
    
LCD_DAT_W_Timing () ;

    
Temp_CMD = (LCD_CMD 0xF0)[color=0000CC]<<2[/color] ;  ;             // Send low nibble to LCD bus
    
LCD_DATA= (LCD_DATA & [color=0000CC]0b11000011[/color])|Temp_CMD ;
    
LCD_DAT_W_Timing () ;

    
LCD_DATA Buf_LATD ;
    
    
LCD_S_Delay() ;                         // Delay 100uS for execution

}


發表於: 2007/10/1 13:40
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: LCD pin define
#7
版主
版主


查看用戶資訊
有關使用PIC_LED.C 如果有位移4-bit的傳送繳未就比較麻煩了。有關 LCD的IC的規格可以在 W201 workshop教材裡找到。LCD 應用說明可以參考 WAP002 教材。

http://www.microchip.com.tw/modules/wfdownloads/viewcat.php?list=W

發表於: 2007/10/1 12:01
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: LCD pin define
#6
高級會員
高級會員


查看用戶資訊
這是程式中的定義!!

發表於: 2007/10/1 11:59
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: LCD pin define
#5
中級會員
中級會員


查看用戶資訊
您好,

剛剛我從Google上面搜尋了一下, 也似乎沒有相關的datasheet

請教一下, 關於LCD_DATA LATD, LCD_CTRL LATA, DIR_LCD_DATA TRISD這些參數的設定值及相關資料我要從何得知?

發表於: 2007/10/1 10:56
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: LCD pin define
#4
高級會員
高級會員


查看用戶資訊
這樣的Pin assign大概不只有改Pin define 這麼簡單..@@

App013 是用4位元的傳輸模式,當初定義是使用PORT 的 Low nibble

如今assign 成 2 3 4 5 那資料必須先做移位處理,Mask也要做調整。還有 6 7 腳要做對應調整。


簡單說就是跟程式相關的LCD_DATA LATD,LCD_CTRL LATA,DIR_LCD_DATA TRISD都要改.

發表於: 2007/10/1 9:54
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: LCD pin define
#3
中級會員
中級會員


查看用戶資訊
救世主板友, 您好
根據您的回應, 我嘗試著依據被改變的pin腳重新定義LCD的程式檔
下面紅色字體是原先程式裡面所定義的RS及RW
可是在將它們Disable, 並填入新的pin定義(藍色)之後
LCD上所顯示, 由之前的亂碼變為一個全滿的方塊出現在cursor的位置
請問, 是否還有其他需要因應pin腳變動而也需更改的設定嗎?

#include "P18F_LCD.h"
#include <p18F4550.h>
#include <delays.h>

//
// Defines for I/O ports that provide LCD data & control
// PORTD[0:3]-->DB[4:7]: Higher order 4 lines data bus with bidirectional
// : DB7 can be used as a BUSY flag
// PORTA,2 --> [E] : LCD operation start signal control
// PORTD,5 --> [RW]: LCD Read/Write control
// PORTD,4 --> [RS]: LCD Register Select control
// : "0" for Instrunction register (Write), Busy Flag (Read)
// : "1" for data register (Read/Write)
//
#define CPU_SPEED 16 // CPU speed is 16 Mhz !!
//#define LCD_RS PORTDbits.RD4 // The definition of control pins
//#define LCD_RW PORTDbits.RD5

#define LCD_RS PORTDbits.RD7
#define LCD_RW PORTDbits.RD6

#define LCD_E PORTEbits.RE2
#define LCD_DATA LATD // PORTD[0:3] as LCD DB[4:7]
//#define LCD_CTRL LATA
#define DIR_LCD_DATA TRISD


// LCD Module commands

#define DISP_2Line_8Bit 0b00111000
#define DISP_2Line_4Bit 0b01010000
//#define DISP_2Line_4Bit 0b00101000
#define DISP_ON 0x00C // Display on
#define DISP_ON_C 0x00E // Display on, Cursor on
#define DISP_ON_B 0x00F // Display on, Cursor on, Blink cursor
#define DISP_OFF 0x008 // Display off
#define CLR_DISP 0x001 // Clear the Display
#define ENTRY_INC 0x006 //
#define ENTRY_INC_S 0x007 //
#define ENTRY_DEC 0x004 //
#define ENTRY_DEC_S 0x005 //
#define DD_RAM_ADDR 0x080 // Least Significant 7-bit are for address
#define DD_RAM_UL 0x080 // Upper Left coner of the Display

unsigned char Temp_CMD ;
unsigned char Str_Temp ;
unsigned char Out_Mask ;
unsigned char Buf_LATD ;


void OpenLCD(void)

{
Buf_LATD = LCD_DATA ;

ADCON1 |= 0b00001100 ; // Set to " Only AN0 .. AN2 are possibly to be set as Analog ..
LCD_E=0;

LCD_DATA = 0x00; // LCD DB[4:7] & RS & R/W --> Low

DIR_LCD_DATA = 0x00; // LCD DB[4:7} & RS & R/W are output function
TRISEbits.TRISE2=0; // Set E pin as output

// LCD_DATA = 0b00000011 ;
LCD_DATA = 0b00000101 ;
LCD_CMD_W_Timing() ;
LCD_L_Delay() ;

// LCD_DATA = 0b00000011 ;
LCD_DATA = 0b00000101 ;
LCD_CMD_W_Timing() ;
LCD_L_Delay() ;

// LCD_DATA = 0b00000011 ;
LCD_DATA = 0b00000101 ;
LCD_CMD_W_Timing() ;
LCD_L_Delay() ;

// LCD_DATA = 0b00000010 ;
LCD_DATA = 0b00000100 ;
LCD_CMD_W_Timing() ;
LCD_L_Delay() ;

WriteCmdLCD(DISP_2Line_4Bit) ;
LCD_S_Delay() ;

WriteCmdLCD(DISP_ON) ;
LCD_S_Delay() ;

WriteCmdLCD(ENTRY_INC) ;
LCD_S_Delay() ;

WriteCmdLCD(CLR_DISP) ;
LCD_L_Delay() ;

LCD_DATA = Buf_LATD ;
}

//*********************************************
// _ ______________________________
// RS _>--<______________________________
// _____
// RW \_____________________________
// __________________
// E ____________/ \___
// _____________ ______
// DB _____________>--------------<______
//***********************************************
// Write Command to LCD module
//
void WriteCmdLCD( unsigned char LCD_CMD)
{
Temp_CMD = (LCD_CMD & 0xF0)>>4 ; // Send high nibble to LCD bus
LCD_DATA= (LCD_DATA & 0xF0)|Temp_CMD ;
LCD_CMD_W_Timing () ;

Temp_CMD = LCD_CMD & 0x0F ; // Send low nibble to LCD bus
LCD_DATA= (LCD_DATA & 0xF0)|Temp_CMD ;
LCD_CMD_W_Timing () ;

LCD_S_Delay() ; // Delay 100uS for execution
}

//***********************************************
// Write Data to LCD module
//
void WriteDataLCD( unsigned char LCD_CMD)
{
Buf_LATD = LCD_DATA ;

Temp_CMD = (LCD_CMD & 0xF0)>>4 ; // Send high nibble to LCD bus
LCD_DATA= (LCD_DATA & 0xF0)|Temp_CMD ;
LCD_DAT_W_Timing () ;

Temp_CMD = LCD_CMD & 0x0F ; // Send low nibble to LCD bus
LCD_DATA= (LCD_DATA & 0xF0)|Temp_CMD ;
LCD_DAT_W_Timing () ;

LCD_DATA = Buf_LATD ;

LCD_S_Delay() ; // Delay 100uS for execution

}

void putcLCD(unsigned char LCD_Char)
{
WriteDataLCD(LCD_Char) ;
}

void LCD_CMD_W_Timing( void )
{
LCD_RS = 0 ; // Set for Command Input
Nop();
LCD_RW = 0 ;
Nop();
LCD_E = 1 ;
Nop();
Nop();
LCD_E = 0 ;
}

void LCD_DAT_W_Timing( void )
{
LCD_RS = 1 ; // Set for Data Input
Nop();
LCD_RW = 0 ;
Nop();
LCD_E = 1 ;
Nop();
Nop();
LCD_E = 0 ;
}

//***********************************************
// Set Cursor position on LCD module
// CurY = Line (0 or 1)
// CurX = Position ( 0 to 15)
//***********************************************

void LCD_Set_Cursor(unsigned char CurX, unsigned char CurY)
{
Buf_LATD = LCD_DATA ;

WriteCmdLCD( 0x80 + CurY * 0x40 + CurX) ;

LCD_DATA = Buf_LATD ;

LCD_S_Delay() ;

}

//***********************************************
// Put a ROM string to LCD Module
//***********************************************

void putrsLCD( const rom char *Str )
{
while (1)
{
Str_Temp = *Str ;

if (Str_Temp != 0x00 )
{
WriteDataLCD(Str_Temp) ;
Str ++ ;
}
else
return ;
}
}

//***********************************************
// Put a RAM string to LCD Module
//***********************************************

void putsLCD( char *Str)
{
while (1)
{
Str_Temp = *Str ;

if (Str_Temp != 0x00 )
{
WriteDataLCD(Str_Temp) ;
Str ++ ;
}
else
return ;
}
}


void puthexLCD(unsigned char HEX_Val)
{
unsigned char Temp_HEX ;

Temp_HEX = (HEX_Val >> 4) & 0x0f ;

if ( Temp_HEX > 9 )Temp_HEX += 0x37 ;
else Temp_HEX += 0x30 ;

WriteDataLCD(Temp_HEX) ;

Temp_HEX = HEX_Val & 0x0f ;
if ( Temp_HEX > 9 )Temp_HEX += 0x37 ;
else Temp_HEX += 0x30 ;

WriteDataLCD(Temp_HEX) ;
}

// *********************************************************************************
// Delay for atleast 10 ms
// *********************************************************************************
void LCD_L_Delay(void)
{
Delay10KTCYx(CPU_SPEED / 2) ;
}

// *********************************************************************************
// Delay for 100 us
// *********************************************************************************
void LCD_S_Delay(void)
{
Delay100TCYx(CPU_SPEED/4) ;

發表於: 2007/10/1 9:43
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: LCD pin define
#2
資深會員
資深會員


查看用戶資訊
板子的PIN腳要和程式定義相同才可以...自己對照電路和程式只要一樣應該就可以了...當然也要注意程式送信號的部分是否有問題...

發表於: 2007/9/29 20:58
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


LCD pin define
#1
中級會員
中級會員


查看用戶資訊
Dear all,
小弟是個新手, 目前正在玩P18F4550這個microchip, 並且成功在DEMO board(APP013)上試過LCD display feaure(顯示 "Hello would").
可是因為某些因素, 在lay板子的時候, LCD那邊的pin腳已被重新定義. 腳位定義如下:

DEMO => Real
RD0 => RD2
RD1 => RD3
RD2 => RD4
RD3 => RD5
RD4 => RD7
RD5 => RD6

在將同一個程式套進去時, LCD雖有power-on, 但顯示亂碼.

請教各位先進, 因應腳位的改變, 我需要更改p18_LCD.c程式中的哪些值?
謝謝

發表於: 2007/9/29 16:40
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------