من این برنامه رو برای راه اندازی lcd نوشتم اما چیزی روی lcd نمایش داده نمیشه
به نظرتون مشکل چیه؟
کامپایلر xc16
به نظرتون مشکل چیه؟
کامپایلر xc16
کد:
#include <xc.h>
#include <p33FJ64GS606.h>
#include <stdio.h>
#include <stdlib.h>
#define FOSC (7370000ULL)
#define FCY (FOSC/2)
#include <libpic30.h>
#include <string.h>
// FBS
#pragma config BWRP = WRPROTECT_OFF // Boot Segment Write Protect (Boot Segment may be written)
#pragma config BSS = NO_FLASH // Boot Segment Program Flash Code Protection (No Boot program Flash segment)
// FGS
#pragma config GWRP = OFF // General Code Segment Write Protect (General Segment may be written)
#pragma config GSS = OFF // General Segment Code Protection (General Segment Code protect is disabled)
// FOSCSEL
#pragma config FNOSC = FRC // Oscillator Source Selection (Internal Fast RC (FRC))
#pragma config IESO = ON // Internal External Switch Over Mode (Start up device with FRC, then switch to user-selected oscillator source)
// FOSC
#pragma config POSCMD = NONE // Primary Oscillator Source (Primary Oscillator disabled)
#pragma config OSCIOFNC = OFF // OSC2 Pin Function (OSC2 is clock output)
#pragma config FCKSM = CSDCMD // Clock Switching Mode bits (Both Clock switching and Fail-safe Clock Monitor are disabled)
// FWDT
//#pragma config WDTPOST = PS32768 // Watchdog Timer Postscaler (1:32,768)
//#pragma config WDTPRE = PR128 // WDT Prescaler (1:128)
#pragma config WINDIS = OFF // Watchdog Timer Window (Watchdog Timer in Non-Window mode)
#pragma config FWDTEN = OFF // Watchdog Timer Enable (Watchdog timer enabled/disabled by user software)
// FPOR
#pragma config FPWRT = PWR128 // POR Timer Value (128ms)
#pragma config ALTSS1 = ON // Enable Alternate SS1 pin bit (SS1A is selected as the I/O pin for SPI1)
#pragma config ALTQIO = ON // Enable Alternate QEI1 pin bit (AQEA1, AQEB1, and AINDX1 are selected as inputs to QEI1)
// FICD
#pragma config ICS = PGD1 // Comm Channel Select (Communicate on PGC1/EMUC1 and PGD1/EMUD1)
#pragma config JTAGEN = OFF // JTAG Port Enable (JTAG is disabled)
#define rs LATDbits.LATD8 /* PORT for E */
#define rw LATDbits.LATD9 /* PORT for RW */
#define en LATDbits.LATD10 /* PORT for RS */
#define TRIS_E TRISDbits.TRISD8 /* TRIS for E */
#define TRIS_RW TRISDbits.TRISD9 /* TRIS for RW */
#define TRIS_RS TRISDbits.TRISD10 /* TRIS for RS */
//LCD Data pins
#define lcdport LATE
void lcd_ini();
void lcdcmd(unsigned char);
void lcddata(unsigned char);
unsigned char data[20]="EngineersGarage";
unsigned int i=0;
void main(void)
{
PTCONbits.PTEN =0;
TRIS_E=0;
TRIS_RW =0;
TRIS_RS =0;
TRISE=0; // Configure Port E as output port
LATE=0;
lcd_ini(); // LCD initialization
while(data[i]!='\0')
{
lcddata(data[i]); // Call lcddata function to send characters
// one by one from "data" array
i++;
__delay_ms(300);
}
}
void lcd_ini()
{
lcdcmd(0x38); // Configure the LCD in 8-bit mode, 2 line and 5x7 font
lcdcmd(0x0C); // Display On and Cursor Off
lcdcmd(0x01); // Clear display screen
lcdcmd(0x06); // Increment cursor
lcdcmd(0x80); // Set cursor position to 1st line, 1st column
}
void lcdcmd(unsigned char cmdout)
{
lcdport=cmdout; //Send command to lcdport=PORTB
rs=0;
rw=0;
en=1;
__delay_ms(10);
en=0;
}
void lcddata(unsigned char dataout)
{
lcdport=dataout; //Send data to lcdport=PORTB
rs=1;
rw=0;
en=1;
__delay_ms(10);
en=0;
}





دیدگاه