Depuis peu, je me suis décider de controler un LCD graphique avec un 16F877 mais celui-ci a un driver Toshiba T6963C.Et quand je teste le programme un peu modifier car sinon il ne fonctionnait pas, il reste bloqué dans la fonction glcd_writebyte(), pourquoi n'en sort-il pas et continue ce qu'il a à faire.

code : ex_glcd.c
#include <16F877.h>
#use delay(clock=4000000)
#fuses HS,NOWDT,NOPROTECT,NOLVP
#include <ex_glcd.h>
#include <function.c>
#byte data = 8
#byte portd=8 //// /WR - - C4;/RD - - C5;C//D- - C6;/RST- - C7;DATA0-7 PORTD0-7 ////

void main() {
set_tris_a(0xff);set_tris_a(0x 00);set_tris_b(0xff);set_tris_ b(0x00);set_tris_d(0xff);set_t ris_d(0x00);set_tris_c(0xff);s et_tris_c(0x00);LCD=portd=data =0x00;
set_tris_c(0x00); // graphic lcd control lines all output
set_tris_b(0xff); //TRIS DATA bus,note:control bus always outputs

glcd_init();
glcd_WriteByte(1, (LCDModeSet|LCDMode_XOR));
glcd_WriteByte(1, (LCDDispMode|LCDDisp_TXT|LCDDi sp_GRH));
glcd_putc("hello");
}
code function.c
#byte data = 8
#byte portd=8 //// /WR - - C4;/RD - - C5;C//D- - C6;/RST- - C7;DATA0-7 PORTD0-7 ////

const int TextHome = 0x78;
const int TextArea = 0x1E; // how many bytes before a new line
const int GraphicsHome = 0x00;
const int GraphicsArea = 0x1E; // how many bytes before a new line

const int AutoModeWrite = 0xB0;
const int AutoModeRead = 0xB1;
const int AutoModeReset = 0xB2;

const int LCDModeSet = 0x80; // send this OR'd with the following
const int LCDMode_OR = 0b0000;
const int LCDMode_XOR = 0b0001;
const int LCDMode_AND = 0b0010;
const int LCDMode_TA = 0b0100; // TEXT ATTRIBUTE mode.
const int LCDMode_RAM = 0b1000; // 1=CG RAM, 0=internal CG ROM

const int LCDSetCursorPtr = 0x21; // cursor address
const int LCDSetCursorSize = 0xA0; // 1 line cursor

const int LCDDispMode = 0x90; // send this OR'd with the following
const int LCDDisp_BLK = 0b0001;
const int LCDDisp_CUR = 0b0010;
const int LCDDisp_TXT = 0b0100;
const int LCDDisp_GRH = 0b1000;

struct lcd_pin_def
{
BOOLEAN unused1; // C0
BOOLEAN unused2; // C1
BOOLEAN unused3; // C2
BOOLEAN unused4; // C3
BOOLEAN w_bar; // C4 Write bar active low
BOOLEAN r_bar; // C5 Read bar active low
BOOLEAN cd; // C6 Command/Data BAR 1=command 0=data
BOOLEAN reset_bar; // C7 Reset active low
};
struct lcd_pin_def LCD;

#byte LCD = 7 // portC address on 16F877

void glcd_init()
{
set_tris_a(0xff);set_tris_a(0x 00);set_tris_b(0xff);set_tris_ b(0x00);set_tris_d(0xff);set_t ris_d(0x00);set_tris_c(0xff);s et_tris_c(0x00);LCD=portd=data =0x00;
set_tris_c(0x00); // graphic lcd control lines all output
set_tris_b(0xff); //TRIS DATA bus,note:control bus always outputs

LCD.w_bar = 1; // INITIAL STATES OF CONTROL PINS
LCD.r_bar = 1; //
LCD.cd = 1; // command

LCD.reset_bar = 0; // perform a reset
delay_us(10); // delay for a reset
LCD.reset_bar = 1; // run

glcd_WriteCmd2(TextHome, 0x40);
glcd_WriteCmd2(TextArea, 0x41);
glcd_WriteCmd2(GraphicsHome, 0x42);
glcd_WriteCmd2(GraphicsArea, 0x43);

// set address to 0
glcd_WriteCmd2(0x0000, 0x24);
glcd_WriteCmd2(0x0000, 0x24);

// Clear all RAM of LCD (8k)
glcd_WriteByte(1, AutoModeWrite);
glcd_WriteByte(1, AutoModeReset);
}

void glcd_WriteByte(int cd2, int data)
{
int status = 0, temp = 0;
set_tris_d(0xff);
LCD.w_bar = 1;
LCD.r_bar= 0;
LCD.cd = 1;
status = portd;

while (status != 0x03) { // is LCD busy?
LCD.r_bar= 0;
portd = temp;
LCD.r_bar = 1;
status = temp & 0x03;
}

set_tris_d(0x00);
LCD.cd = cd2; // Command/Data bar
portd = data;
LCD.r_bar = 1; // not read
LCD.w_bar = 0; // write
LCD.w_bar = 1; // release
}

void glcd_WriteByteAuto(int data)
{
int status = 0, temp = 0; // status bits ARE DIFFERENT BITS THAN NORMAL
set_tris_b(0xff);
LCD.w_bar = 1;
LCD.r_bar = 1;
LCD.cd = 1; // defaults
status=portd;

while (status != 0x08) { // is LCD busy?
LCD.r_bar = 0;
temp = portd;
LCD.r_bar = 1;
status = temp & 0x08;
}

set_tris_d(0x00); // All outputs
LCD.cd = 0; // This is always data, cd=0
portd = data; // Put data on data bus
LCD.w_bar = 0; // write
LCD.w_bar = 1; // release
}

void glcd_WriteCmd1(int data, int cmd)
{
glcd_WriteByte(0, data);
glcd_WriteByte(1, cmd);
}

void glcd_WriteCmd2(int data, int cmd)
{
glcd_WriteByte(0, data & 0xff);
glcd_WriteByte(0, data>>8);
glcd_WriteByte(1, cmd);
}

int glcd_ReadByte(void)
{
int data = 0, status = 0, temp = 0;
set_tris_b(0xff);
LCD.w_bar = 1;
LCD.r_bar = 1;
LCD.cd = 1; // defaults
status=portd;

#asm nop #endasm

while (status != 0x03) { // is LCD busy?
LCD.r_bar = 0;
temp = portd;
LCD.r_bar = 1;
status = temp & 0x03;
}

LCD.cd = 0; // Command/Data bar
LCD.r_bar = 0; // read
/////////////////////////////////////////////////////////
#asm nop #endasm // THIS PAUSE IS VERY NESSESARY !!!//
/////////////////////////////////////////////////////////
data = portd;
LCD.r_bar = 1;
LCD.cd = 1;
return data; // Return the read data
}

void glcd_putc(char c) {
glcd_WriteCmd1(c - 0x20, 0xc0);
}

void glcd_gotoxy(int x, int y, int text) { // sets memory location to screen location x, y
// location 1,1 is upper left corner; text = 1 (text area), text = 0 (graphics area)
int location, home;
int line;

if (!text) {
home = GraphicsHome;
line = GraphicsArea;
}
else {
home = TextHome;
line = TextArea;
}

location = home + (((int)y - 1) * line) + x - 1;
glcd_WriteCmd2(location, 0x24);
}
code : ex_glcd.h
extern int glcd_ReadByte(void);
extern void glcd_WriteByte(int cd, int data);
extern void glcd_WriteByteAuto(int data);
extern void glcd_WriteCmd2(int data, int cmd);
extern void glcd_WriteCmd1(int data, int cmd);
extern void glcd_gotoxy(int x, int y, int1 text);
extern void glcd_init();

Merci d'avance