Bonjour à tous,
J'ai un petit souci pour afficher du texte sur un afficheur LCD 2x16.
datasheet: http://www.farnell.com/datasheets/1485447.pdf
L'erreur doit etre au niveau du programme:
Merci d'avance pour votre aide.Code:#include <p18f2525.h> #include "main.h" #include <sw_uart.h> #include <stdlib.h> #include <string.h> #include <timers.h> // Timer library functions #include <delays.h> #include <math.h> #include <stdio.h> #include <portb.h> #pragma code //--------------------------------------------------------------------- //interruption haute //--------------------------------------------------------------------- #pragma interrupt High_isr void High_isr(void) { unsigned char a; if (PIR1bits.RCIF == 1) //interruption voie série 1 réception { //ceci raz le flag // PIR1bits.RCIF = 0; a = RCREG; // Clear the overrun error condition if (RCSTAbits.FERR || RCSTAbits.OERR) { RCSTAbits.CREN = 0; RCSTAbits.CREN = 1; } if (a != 0xa) { if (a == 0x0d) { *p_ecrit_buffe = 0; p_ecrit_buffe = buffe; flag.b_SERIE_RX = 1; } else *p_ecrit_buffe++ = a; } } } //--------------------------------------------------------------------- //interruption basse //--------------------------------------------------------------------- #pragma interrupt Low_isr void Low_isr(void) { } #pragma code // LCD #define RS PORTBbits.RB2 #define EN PORTBbits.RB0 #define LCD_OUT PORTC // delay function void _delay_us (unsigned char us) { while(us--) { Nop(); Nop(); } } void _delay_ms(unsigned char ms) { unsigned char i, j; while(ms--){ for (i = 0; i < 20; i++) for (j = 0; j < 100; j++) Nop(); }; } // void LCD_STROBE void LCD_STROBE() { EN=1; EN=0; } void LCD_DATA(unsigned char c) { unsigned char temp, h_nibble, l_nibble; RS=1; _delay_us(50); // delay 50us temp=LCD_OUT&0xF0; h_nibble=(c>>4)&0x0F; l_nibble=c&0x0F; LCD_OUT = temp|h_nibble; /// send 4 high bit LCD_STROBE(); LCD_OUT=temp|l_nibble; // send 4 low bit LCD_STROBE(); _delay_us(50); } void LCD_CMD(unsigned char c) { unsigned char temp, h_nibble, l_nibble; RS = 0; _delay_us(50); temp=LCD_OUT&0xF0; h_nibble=(c>>4)&0x0F; l_nibble=c&0x0F; LCD_OUT = temp|h_nibble; //// send 4 high bit // LCD_STROBE(); // LCD_OUT=temp|l_nibble; // send 4 low bit LCD_STROBE(); _delay_us(50); } void clear(void) // Clear dislay { LCD_CMD(0x10); _delay_ms(2); } void LCD_INIT() { TRISC = 0; TRISB = 0; RS = 0; _delay_ms(100); LCD_CMD(0x30); _delay_ms(10); LCD_CMD(0x30); _delay_ms(1); LCD_CMD(0x30); LCD_CMD(0x20); LCD_CMD(0x20);// Function set (4 bit mode) 0010 1000 LCD_CMD(0x80); LCD_CMD(0x00); // Display OFF LCD_CMD(0xF0); LCD_CMD(0x00);// Display clear LCD_CMD(0x10); LCD_CMD(0x00); //Entry mode set LCD_CMD(0x40); } void string(const char *q) { while(*q) { LCD_DATA(*q++); } } //--------------------------------------------------------------------- //MAIN //--------------------------------------------------------------------- void main(void) { RS = 0; LCD_INIT(); string("TEST"); }
-----