Bonjour,
j ai l impression que mon code est correct mais vu que ca n affiche rien, il doit y avoir une erreur.
si quelqu un sait m aider.

merci d avance

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
// LCD Routines for "CP-JR ARM7 USB-LPC2148" 
// Character 16x2 8-Bit Mode Interface 
// RS = P1.25
// RW = P1.26	
// EN = P1.27					 
// D4 = P1.28						   
// D5 = P1.29						   
// D6 = P1.30						   
// D7 = P1.31
 
// D0 = P0.12
// D1 = P0.13
// D2 = P0.14
// D3 = P0.15
 
#include <LPC21xx.H>                            // LPC2119 MPU Register 
 
// Define LCD PinIO Mask 
#define  LCD_D7     0x80000000//p1.31   
#define  LCD_D6     0x40000000//p1.30   
#define  LCD_D5     0x20000000//p1.29    
#define  LCD_D4     0x10000000//p1.28    
#define  LCD_D3     0x00008000//p0.15   
#define  LCD_D2     0x00004000//p0.14   
#define  LCD_D1     0x00002000//p0.13   
#define  LCD_D0     0x00001000//p0.12   
#define  LCD_EN     0x08000000//p1.27  
#define  LCD_RW     0x04000000//p1.26   
#define  LCD_RS     0x02000000//p1.25    
#define  LCD_DATA   (LCD_D4|LCD_D5|LCD_D6|LCD_D7) 
#define  LCD_DATA2  (LCD_D0|LCD_D1|LCD_D2|LCD_D3)
 
#define  lcd_rs_set() IOSET1 |= LCD_RS   // RS = 1 (Select Instruction) 
#define  lcd_rs_clr() IOCLR1 |= LCD_RS   // RS = 0 (Select Data) 
#define  lcd_en_set() IOSET1 |= LCD_EN   // EN = 1 (Enable) 
#define  lcd_en_clr() IOCLR1 |= LCD_EN   // EN = 0 (Disable) 
#define  lcd_rw_set() IOSET1 |= LCD_RW   // RW = 1 (Enable) 
#define  lcd_rw_clr() IOCLR1 |= LCD_RW   // RW = 0 (Disable) 
 
#define  LCD_IOALL  (LCD_D7|LCD_D6|LCD_D5|LCD_D4|LCD_RS|LCD_RW|LCD_EN)
#define  LCD_IOALL2 (LCD_D3|LCD_D2|LCD_D1|LCD_D0)
 
#define  lcd_dir_write()  IODIR1 |= 0xFE000000			// LCD Data Bus = Write
#define  lcd_dir2_write() IODIR0 |= 0x0000F000
#define  lcd_dir_read()   IODIR1 &= 0x0FFFFFFF			// LCD Data Bus = Read 
#define  lcd_dir2_read()  IODIR0 &= 0xFFFF0FFF
 
#define  lcd_clear()          lcd_write_control(0x01)   // Clear Display 
#define  lcd_cursor_home()    lcd_write_control(0x02)   // Set Cursor = 0 
#define  lcd_display_on()     lcd_write_control(0x0E)   // LCD Display Enable 
#define  lcd_display_off()    lcd_write_control(0x08)   // LCD Display Disable 
#define  lcd_cursor_blink()   lcd_write_control(0x0F)   // Set Cursor = Blink 
#define  lcd_cursor_on()      lcd_write_control(0x0E)   // Enable LCD Cursor 
#define  lcd_cursor_off()     lcd_write_control(0x0C)   // Disable LCD Cursor 
#define  lcd_cursor_left()    lcd_write_control(0x10)   // Shift Left Cursor 
#define  lcd_cursor_right()   lcd_write_control(0x14)   // Shift Right Cursor 
#define  lcd_display_sleft()  lcd_write_control(0x18)   // Shift Left Display 
#define  lcd_display_sright() lcd_write_control(0x1C)   // Shift Right Display 
 
/* pototype  section */ 
 
void lcd_out_data8(unsigned char);      // Strobe 8-Bit Data to LCD 
void lcd_write_byte(unsigned char);      // Write 1 Byte Data to LCD 
void lcd_write_control(unsigned char);       // Write Instruction 
void lcd_write_ascii(unsigned char);       // Write LCD Display(ASCII) 
void goto_cursor(unsigned char);      // Set Position Cursor LCD 
void lcd_print(unsigned char*);      // Print Display to LCD 
void delay(unsigned long int);      // Delay Function 
void enable_lcd(void);	 								// Enable Pulse
char busy_lcd(void);
void lcd_init();
 
/* Main Program Start Here */ 
int main(void) 
{  
  lcd_init();
 
  while(1){
  	goto_cursor(0x00);
	lcd_print(" 8bits  ");
	goto_cursor(0x40);
	lcd_print(" essai  ");
 
  } 
 
} 
 
/****************************/ 
/* Strobe 8-Bit Data to LCD */ 
/****************************/ 
void lcd_out_data8(unsigned char val) 
{ 
  IOCLR1 |= (LCD_DATA);                             // Reset 4-Bit Pin Data 
  IOSET1 |= (((val&0xF0)>>4)<<28);                            IOCLR0 |= (LCD_DATA2);
  IOSET0 |= (val&0x0f)<<12;
 
} 
 
/****************************/ 
/* Write Data 1 Byte to LCD */ 
/****************************/ 
void lcd_write_byte(unsigned char val) 
{  
  lcd_out_data8(val);
  enable_lcd();
  while(busy_lcd()); 
 
 
} 
 
/****************************/ 
/* Write Instruction to LCD */ 
/****************************/ 
void lcd_write_control(unsigned char val) 
{ 
  lcd_rs_clr();                                 // RS = 0 = Instruction Select 
  lcd_write_byte(val);                           // Strobe Command Byte     
} 
 
/****************************/ 
/* Write Data(ASCII) to LCD */ 
/****************************/ 
void lcd_write_ascii(unsigned char c) 
{ 
  lcd_rs_set();                                 // RS = 1 = Data Select 
  lcd_write_byte(c);                              // Strobe 1 Byte to LCD    
} 
 
 
/************************************/ 
/* Print Display Data(ASCII) to LCD */ 
/************************************/ 
void lcd_print(unsigned char* str) 
{ 
  int i; 
  for (i=0;i<16 && str[i]!=0;i++)                    // 16 Character Print 
  { 
    lcd_write_ascii(str[i]);                     // Print Byte to LCD 
  } 
} 
 
/***********************/ 
/* Delay Time Function */ 
/*    1-4294967296     */ 
/***********************/ 
void delay(unsigned long int count1) 
{ 
  while(count1 > 0) {count1--;}                     // Loop Decrease Counter    
} 
 
/***************************/
/* Set LCD Position Cursor */
/***************************/
void goto_cursor(unsigned char i)
{
  i |= 0x80;											// Set DD-RAM Address Command
  lcd_write_control(i);  
}
 
/******************/
/* Wait LCD Ready */
/******************/
 
char busy_lcd(void)
{
  unsigned long busy_status;							// Busy Status Read
  unsigned int i;										// Delay Count
 
  lcd_dir_read();
  lcd_dir2_read();										// LCD Data Bus = Read
  lcd_rs_clr();		 									// Instruction Select
  lcd_rw_set(); 										// Read Direction
  lcd_en_set();											// Start Read Busy
 
  for (i=0;i<1000;i++);	  								// Delay Before Read
  busy_status = (IOPIN1 & 0x80000000);					// Read LCD Data 
  if(busy_status == 0x80000000)  						// Read & Check Busy Flag
  {
    lcd_en_clr();  										// Disable Read
	lcd_rw_clr();										// Default = Write Direction
	lcd_dir_write();
	lcd_dir2_write();									// LCD Data Bus = Write
    return 1;											// LCD Busy Status
  }
  else
  {
    lcd_en_clr();  										// Disable Read
	lcd_rw_clr();										// Default = Write Direction
	lcd_dir_write();
	lcd_dir2_write();									// LCD Data Bus = Write
    return 0;											// LCD Ready Status
  }
}
void lcd_init()
{
  unsigned int i;										// LCD Initial Delay Count 
 
  PINSEL2  = 0x00000000;								// GPIO1[31..26] = I/O Function
  PINSEL0 = 0x00000000;
  lcd_dir_write();
  lcd_dir2_write();										// LCD Data Bus = Write
  for (i=0;i<50000;i++);								// Power-On Delay (15 mS)
 
  IOCLR1 = (LCD_IOALL);
  IOCLR0 = (LCD_IOALL2);								// Reset (RS,RW,EN,4-Bit Data) Pin
  IOSET1 = (LCD_D5|LCD_D4);								
  enable_lcd();											// Enable Pulse
  for (i=0;i<10000;i++);								// Delay 4.1mS
 
  IOCLR1 = (LCD_IOALL);
  IOCLR0 = (LCD_IOALL2);	  							// Reset (RS,RW,EN,4-Bit Data) Pin
  IOSET1 = (LCD_D5|LCD_D4);								 
  enable_lcd();											// Enable Pulse
  for (i=0;i<100;i++);									// delay 100uS
 
  IOCLR1 = (LCD_IOALL);
  IOCLR0 = (LCD_IOALL2);	  							// Reset (RS,RW,EN,4-Bit Data) Pin
  IOSET1 = (LCD_D5|LCD_D4);								
  enable_lcd();											// Enable Pulse
  while(busy_lcd());      								// Wait LCD Execute Complete
 
  IOCLR1 = (LCD_IOALL);	
  IOCLR0 = (LCD_IOALL2);  								// Reset (RS,RW,EN,4-Bit Data) Pin
  IOSET1 = (LCD_D5);									
  enable_lcd();											// Enable Pulse
  while(busy_lcd());      								// Wait LCD Execute Complete
 
  delay(200);
  lcd_write_control(0x38);     						// Function Set (DL=1 8-Bit,N=1 2 Line,F=0 5X7)
  delay(50);
  lcd_write_control(0x08);				 
  delay(50);
  lcd_write_control(0x0C);  							// Display on/off Control (Entry Display,Cursor off,Cursor not Blink)
  delay(50);
  lcd_write_control(0x01);  							// Clear Display  (Clear Display,Set DD RAM Address=0) 
  delay(2000);
  lcd_write_control(0x06);  							// Entry Mode Set (I/D=1 Increment,S=0 Cursor Shift)
  delay(50);
 
  for (i=0;i<100000;i++);								// Wait Command Ready
}
/***********************/
/* Enable Pulse to LCD */
/***********************/
void enable_lcd(void)	 								// Enable Pulse
{
  unsigned int i;										// Delay Count
  lcd_en_set();  										// Enable ON
  for (i=0;i<50;i++);
  lcd_en_clr();  										// Enable OFF 
}