Bonjour,
je veux gérer un afficheur en i2c j'ai copié exactement le même montage que j'ai trouvé il marche.
Mais le programme que j'ai n'est pas pour un pic18f4550 donc je l'ai transformé pas d'erreur a la compilation.
J'arrive a faire clignoter une led donc mes fusibles doivent être bien configurer sur mon quartz externe 20Mhz pour le pic.
Ma question pourquoi sa marche pas ? :
la pièce jointe c'est juste le schéma du pcf8574 et du picCode:// // // #include <p18f4550.h> #include <i2c.h> #include <stdlib.h> void init(); void init_lcd(); void tempo(void); void tempo2(unsigned int); void I2c(unsigned char); void envoi(unsigned char); void lcd_putc(char); void clear_lcd(); void ligne_up(); // // // #define addresse_LCD 0x40 //-----declaration des variable globale----------------------------------------- //----------------Fonction Global-------------------------------------------------------------- void envoi(unsigned char data) { data=data|0x040;//E est a 1 I2c(data); tempo(); data=data-1;//E=0 I2c(data); tempo(); } void I2c(unsigned char data) {StartI2C(); WriteI2C(addresse_LCD); WriteI2C(data); StopI2C(); } void affich(char mess) { char data; data=mess&0xF0; data=data+4; //RS a 1 envoi(data); data=mess&0x0F; data=data<<4; data=data+4;//RS a 1 envoi(data); } void lcd_putc(char c) { switch(c) { case'\f': clear_lcd(); break; case'\n': ligne_up(); break; default: affich(c); break; } } void clear_lcd() { envoi(0x00); envoi(0x10); } void ligne_up() { //40h envoi(0xC0); envoi(0x00); tempo(); } void init_lcd() //fonction qui marche { tempo(); tempo(); tempo(); //On travaille sur la commande donc RS=0 R/W=0 écriture envoi(0x00); envoi(0x10); envoi(0x00); envoi(0x00); envoi(0x10); //mode 8 bits envoi(0x30); envoi(0x30); envoi(0x30); //mode 4 bits envoi(0x20); //mode 4 bits, 2 lignes, caractères 5x7 (28h) envoi(0x20); envoi(0x80); //affichage en fonction, pas de curseur (0Ch) envoi(0x00); envoi(0xc0); //le curseur se déplace vers la gauche (06h) envoi(0x00); envoi(0x60); //on efface l'afficheur envoi(0x00); envoi(0x10); while(1) { lcd_putc("\fFonctionne"); tempo2(7); lcd_putc("\f"); lcd_putc("Mon LCD\nI2C"); tempo2(7); //20000 3s -2000 370ms- 130 20ms 65 11ms 6=1ms4 4=1ms de boucle } } void tempo()//fonction qui marche { unsigned int j; for(j=0; j<2000; j++); } void tempo2(unsigned int t)//fonction qui marche { unsigned int j; for(j=0; j<t; j++); } void init() { TRISC = 1; //portc en entree TRISD = 0; //portd en entree TRISD= 0xEF;//portd4 sortie TRISD= 0xDF;//portd5 sortie TRISD= 0x7F;//portd7 sortie LATDbits.LATD4 = 0; //led4 éteinte LATDbits.LATD5 = 0; //led3 éteinte LATDbits.LATD7 = 0; // LED éteinte } void main() { init(); LATDbits.LATD4 = 1; //led4 allumé LATDbits.LATD5 = 1; //led3 allumé LATDbits.LATD7 = 1; //led2 allumé OpenI2C(MASTER, SLEW_OFF);// init_lcd();// CloseI2C(); }
pcf8574 dont je suis pas sur de connaître son adresse et l'afficheur dont je ne sais pas comment connaître l'adresse si c'est le problème dans mon programme
Si vous avez une solution je vous en serais reconnaisant.
Merci
-----