⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcdio.c

📁 本程序是基于PIC24的Calculator程序,其实现Calculator多个功能,具体自己体会,这程序旨在让大家熟悉PIC24的编程问题.
💻 C
字号:
/*********************************************************************
**********************************************************************
*****                                                             ****
*****         L A B C E N T E R    E L E C T R O N I C S          ****
*****                                                             ****
*****                    PIC PIC 24FJ64GA006 LCD Driver           ****
*****                                                             ****
**********************************************************************
*********************************************************************/

#include "p24FJ64GA006.h"
#include "calc.h"

VOID lcd_init ()
// Initialise the LCD Display. 
 { PORTD = 0;
   TRISD = 0; 
   wrcmd(0x30);                  // 8-bit mode - 1 line.
   wrcmd(LCD_SETVISIBLE+0x04);   // Display only - no cursors.
   wrcmd(LCD_SETMODE+0x03);      // Automatic Increment - Display shift left.
   wrcmd(LCD_SETDDADDR+0x0F);    // Initial Position far right.
 }

VOID clearscreen ()
// Clear the LCD Screen and reset
// initial position.
 { wrcmd(LCD_CLS);
   wrcmd(LCD_SETDDADDR+0x0F);
 }

/***** Utility Functions *****/

VOID wrcmd (BYTE cmdcode)
// Write a command to the LCD display.
 { TRISD = 0x0000; 
   PORTD = LCD_CMD_WR | cmdcode;

   // Toggle Pin 'E' to send the command.
   PORTD |= E_PIN_MASK;
   nop();
   PORTD &= ~E_PIN_MASK;
   
   lcd_wait();
 }
     
VOID wrdata (BYTE data)
// Write a Character to the LCD Display. 
 { TRISD = 0x0000;
   PORTD = LCD_DATA_WR | data;

   // Toggle Pin 'E' to send the command.
   PORTD |= E_PIN_MASK;
   nop(); 
   nop();
   nop();
   nop();
   PORTD &= ~E_PIN_MASK;
   
   lcd_wait();
 }

VOID lcd_wait ()
// Wait for the LCD busy flag to clear. 
 { BYTE status;
   TRISD |= 0x00FF;
   PORTD = LCD_BUSY_RD;
   do
    { PORTD |= E_PIN_MASK;
	   nop(); 
	   nop();
	   nop();
	   nop();
      status = PORTD;
      PORTD &= ~E_PIN_MASK;
    } while (status & 0x80);
 }


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -