Encore une bizarrerie avec MPLAB XC8 2.36
test d'un afficheur LCd 2x16 avec une interface I2C1 via un PCF8754 @=0x20 (7 bits)
Affichage OK sauf que
Test cde I2C LCD PCF8754 @0x20 (7 bits) ..OK
test LCD avec problemo:
Code : Tout sélectionner
unint16_t i,j,k;
void LCD_putch(unsigned char d)
{
static unsigned char lcddata;
// Put the Upper 4 bits data on P0 ..P3
lcddata =( (d & 0xF0) >>4 )| LCD_RS;
I2C_PCF8574_Write(Addr,lcddata | LCD_EN);
__delay_us(5); // __delay 2us for 16 MHz Internal Clock
// Write Enable Pulse E: Hi -> Lo
lcddata = ( ( (d & 0xF0) >>4 ) | LCD_RS ) & (~LCD_EN) ;
I2C_PCF8574_Write(Addr,lcddata);
__delay_us(15); // __delay 1us for 16 MHz Internal Clock
// Put the Lower 4 bit data
lcddata = (d & 0x0F) | LCD_RS | LCD_EN;
I2C_PCF8574_Write(Addr,lcddata);
__delay_us(15); // __delay 2us for 16 MHz Internal Clock
// Write Enable Pulse E: Hi -> Lo
lcddata = ( (d & 0x0F) | LCD_RS ) & (~LCD_EN);
I2C_PCF8574_Write(Addr,lcddata);
__delay_us(15); // __delay 1us for 16 MHz Internal Clock
}
void LCD_Write_CText(const char *txt)
{ static int i1;
i1=0;
while ((*txt) && (i1<16))
i1++;
LCD_putch(*(txt++));
__delay_ms(2);
}.... main programme ....
.. init hardware,uart,i2C ..
i=0;
while (1)
{
sprintf(CRam1,"I=% 5d 0X%04X ",i,i);
Print(CRam1);CRLF1();
i++;
SQA=1;
LCD_Write_Text_At(2,1,CRam1);
SQA=0;
__delay_ms(500);
__asm("btg LATB,5");
}
Affichage 1ere ligne "ABCDEFGHIJKLMNOP"
affichage sur 2em ligne du LCD (avec ^= espace)
I=^^125^0x007D^^
valeurs de I , uniquement Impaires comme si on faisait i=i+2 !
alors que sur le terminal YAT , on a bien une progression de 1
Test analyser SQA dans 4 sec
Init LCD I2C via PCF8754
123456789A Affichage sur LCD
Erase Line 1
Affichage LCD_Chr_AT(1,3,'0');
Erase Line 2
I= 0 0X0000
I= 1 0X0001
I= 2 0X0002
I= 3 0X0003
I= 4 0X0004
I= 5 0X0005
I= 6 0X0006
I= 7 0X0007
I= 8 0X0008
I= 9 0X0009
encore un mystere et boule de suif !!
une idée ? nota : ma version 18F26K22 sous mikroC tourne OK sans probleme !
test uniquement de l'envoi I2C vers le PCF via SQA analyser

doublon !