• slider image 514
  • slider image 516
  • slider image 517
  • slider image 518
  • slider image 519
:::


Browsing this Thread:   1 Anonymous Users






d30f LCD
#1
新會員
新會員


查看用戶資訊
大大您好 小弟又上來麻煩伱了 不好意思
這是APP023_3的GLCD測試程式
小弟只改了p30fxxxx.h-->p30F6010a.h
想說先看看這程式能run起來在修,可是好像不行,想請大大們給一下指導好嗎?
附檔是rum的結果與設定
請您幫忙一下 謝謝!
#include    <p30F6010a.h>

#include    "GLCD_30IO_APP023.h"

#define        CPU_FCY        16

#define        LCD_RS        LATBbits.LATB10        //    RS = 1 >> Data , =0 >> Command
#define        LCD_RW        LATBbits.LATB11        //  RW = 0 >> Write , = 1 >> Read
#define        LCD_E        LATGbits.LATG9

#define        DIR_LCD_RS    TRISBbits.TRISB10
#define        DIR_LCD_RW    TRISBbits.TRISB11
#define        DIR_LCD_E    TRISGbits.TRISG9

unsigned char    LCD_StatusByte ;

int    LCDIsBusy(void)
{
    
int    BusyLoop ;

    for (
BusyLoop BusyLoop 30 BusyLoop++) ;

        
LCD_StatusByte cmdreadLCD() ;

    for (
BusyLoop BusyLoop 30 BusyLoop++) ;

            return ((
LCD_StatusByte >> 7) & 0x0001) ;
}

void    LCD_Initial(void)
{
        
TRISD &= 0b1111011110000000 ;

        
LCD_E ;

        
DIR_LCD_RS ;
        
DIR_LCD_RW ;
        
DIR_LCD_E ;
        
        
LCD_E_Delay() ;

        
cmdwriteLCD(0x00) ;
        
LCD_Delay200usX(40) ;
        
cmdwriteLCD(0x30) ;
        
LCD_Delay200usX(25);            // Wait for > 4.1 ms --> 200us * 25 = 5 ms
        
cmdwriteLCD(0x30) ;
        
LCD_Delay200usX(20) ;
        
cmdwriteLCD(0x30) ;
        
LCD_Delay200usX(10) ;
        
cmdwriteLCD(0x08) ;
        
LCD_Delay200usX(10) ;
        
cmdwriteLCD(0x01) ;
        
LCD_Delay200usX(50) ;                // Display OFF
        
cmdwriteLCD(0x06) ;
        
LCD_Delay200usX(10) ;            // Clear Display = 1.5 ms 
        
cmdwriteLCD(0x30) ;
        
LCD_Delay200usX(10) ;
        
cmdwriteLCD(0x08) ;                    // Display ON 
        
LCD_Delay200usX(10) ;
        
cmdwriteLCD(0x0e) ;
        
LCD_Delay200usX(10) ;
        
cmdwriteLCD(0x06) ;                    // Display ON 
        
LCD_Delay200usX(50) ;
}

void    setcurLCDchar Cur_X char Cur_Y )
{
 
        
unsigned char    BaseAddr ;

        switch ( 
Cur_Y )
        {
            case    
:
                    
BaseAddr 0x80 ;
                    break ;
            case    
:
                    
BaseAddr 0x90 ;
                    break ;
            case    
:
                    
BaseAddr 0x88 ;
                    break ;
            case    
:
                    
BaseAddr 0x98 ;
                    break ;
            default :
                    
BaseAddr 0x80 ;
                    break ;
        }
            
BaseAddr += Cur_X ;
            while ( 
LCDIsBusy()) ;
            
cmdwriteLCD(BaseAddr) ;

}


void     putcLCDunsigned char TheChar)
{
            
datawriteLCD((unsigned int)TheChar);
}

void    putsLCDunsigned char *OutString )
{
        while ( *
OutString != 0x00 )
        {
             while ( 
LCDIsBusy() );
            
putcLCD( *OutString++ ) ;
        }
}

void    putrsLCD( const unsigned char *OutString )
{
        while ( *
OutString != 0x00 )
        {
             while ( 
LCDIsBusy() );
            
putcLCD( *OutString++ ) ;
        }
}

void     LCD_Delay200usX(int    UnitOf200us)
{
        
int        Loop_200usX ;

        for ( 
Loop_200usX Loop_200usX UnitOf200us Loop_200usX ++ )
        
LCD_Delay200us( ) ;
}

void     LCD_Delay200us(void)
{
    
int        Loop_200us ;

    for ( 
Loop_200us Loop_200us CPU_FCY 40  Loop_200us++)    ;

}


//        LCD Data @ RD0 .. RD6 and RD10
unsigned char    datareadLCD(void)                //    Read data from LCD
{
        
int                Temp_PORTD ;
        
int                Return_Data ;
        
TRISD |= 0b0000100001111111 ;            // Make all LCD data pins as INPUT 
        
LCD_RS ;
        
LCD_RW ;
        
LCD_E_Delay() ;
        
LCD_E ;
        
LCD_E_Delay() ;
        
Temp_PORTD PORTD ;
        
LCD_E ;
        
TRISD &= 0b1111011110000000 ;
        
Return_Data Temp_PORTD ;
        if ( 
Temp_PORTD 0b0000100000000000 )         Return_Data |= 0b10000000 ;
        else                                        
Return_Data &= 0b01111111 ;

        return     (
unsigned char)Return_Data ;
}

unsigned char    cmdreadLCD(void)                //    Read data from LCD
{
        
int                Temp_PORTD ;
        
int                Return_Data ;

        
TRISD |= 0b0000100001111111 ;            // Make all LCD data pins as INPUT 
        
LCD_RS ;
        
LCD_RW ;
        
LCD_E_Delay() ;
        
LCD_E ;
        
LCD_E_Delay() ;
        
Temp_PORTD PORTD ;
        
LCD_E ;
        
TRISD &= 0b1111011110000000 ;
        
Return_Data Temp_PORTD ;
        if ( 
Temp_PORTD 0b0000100000000000 )         Return_Data |= 0b10000000 ;
        else                                        
Return_Data &= 0b01111111 ;

        return    (
unsigned char)Return_Data ;
}

void    datawriteLCD(unsigned char wdata)        // Write data to LCD
{
        
LATD &= 0b1111011110000000 ;
        if ( 
wdata 0b0000000010000000 )
            
LATD |=  0b0000100000000000 ;
            
wdata &= 0b01111111 ;
        
LATD |= wdata ;
        
LCD_RS ;
        
LCD_RW ;
        
LCD_E_Delay() ;
        
LCD_E ;
        
LCD_E_Delay() ;
        
LCD_E ;
        
LCD_E_Delay() ;
}

void    cmdwriteLCD(unsigned char wdata)        // Write Command to LCD 
{
        
LATD &= 0b1111011110000000 ;
        if ( 
wdata 0b0000000010000000 )
            
LATD |=  0b0000100000000000 ;
            
wdata &= 0b01111111 ;
        
LATD |= wdata ;
        
LCD_RS ;
        
LCD_RW ;
        
LCD_E_Delay() ;
        
LCD_E ;
        
LCD_E_Delay() ;
        
LCD_E ;
        
LCD_E_Delay() ;
}

void    LCD_E_Delay(void)
{
        
int    E_Loop ;
        for ( 
E_Loop E_Loop CPU_FCY E_Loop ++ ) ;
}

Attach file:


Link only for registered users

發表於: 2009/9/10 0:23
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... ]

教育訓練中心

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